// Path: src/main/java/com/jeanchampemont/notedown/note/persistence/Note.java
// @Entity
// @Table(name = "note")
// public class Note {
//     @Id
//     @Type(type = "uuid-char")
//     private UUID id;
// 
//     @Column(name = "title", length = 64, nullable = false)
//     private String title;
// 
//     @Column(name = "content", nullable = false)
//     @Lob
//     @Type(type = "org.hibernate.type.StringClobType")
//     private String content;
// 
//     @Column(name = "last_modification", nullable = false)
//     @Temporal(TemporalType.TIMESTAMP)
//     private Date lastModification;
// 
//     @ManyToOne(fetch = FetchType.EAGER)
//     @JoinColumn(name = "user_id", nullable = false)
//     private User user;
// 
//     @OneToMany(mappedBy = "note", cascade = CascadeType.REMOVE)
//     @OrderBy("version DESC")
//     private List<NoteEvent> events = new ArrayList<>();
// 
//     public Note() {
//         id = UUID.randomUUID();
//     }
// 
//     public Note(String title, String content, User user) {
//         id = UUID.randomUUID();
//         this.title = title;
//         this.content = content;
//         this.user = user;
//     }
// 
//     public UUID getId() {
//         return id;
//     }
// 
//     public void setId(UUID id) {
//         this.id = id;
//     }
// 
//     public String getTitle() {
//         return title;
//     }
// 
//     public void setTitle(String title) {
//         this.title = title;
//     }
// 
//     public String getContent() {
//         return content;
//     }
// 
//     public void setContent(String content) {
//         this.content = content;
//     }
// 
//     public Date getLastModification() {
//         return lastModification;
//     }
// 
//     public void setLastModification(Date lastModification) {
//         this.lastModification = lastModification;
//     }
// 
//     public User getUser() {
//         return user;
//     }
// 
//     public void setUser(User user) {
//         this.user = user;
//     }
// 
//     public List<NoteEvent> getEvents() {
//         return events;
//     }
// 
//     public void setEvents(List<NoteEvent> events) {
//         this.events = events;
//     }
// 
//     @Transient
//     public Long getFirstAvailableVersion() {
//         if (events == null || events.size() == 0) {
//             return 0L;
//         } else {
//             return events.get(events.size() - 1).getId().getVersion();
//         }
//     }
// 
//     @Transient
//     public Long getLastVersion() {
//         if (events == null || events.size() == 0) {
//             return 0L;
//         } else {
//             return events.get(0).getId().getVersion();
//         }
//     }
// }


import com.jeanchampemont.notedown.note.persistence.Note;
import javax.persistence.*;
import java.util.HashSet;
import java.util.Set;
/*
 * Copyright (C) 2014, 2015 NoteDown
 *
 * This file is part of the NoteDown project.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *  http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.jeanchampemont.notedown.user.persistence;



@Entity
@Table(name = "user_account")
public class User {
    @Id
    @GeneratedValue(strategy = GenerationType.TABLE)
    private long id;

    @Column(name = "email", unique = true, length = 64)
    private String email;

    @Column(name = "password", length = 60)
    private String password;

    @OneToMany(fetch = FetchType.LAZY, mappedBy = "user")
// Path: src/main/java/com/jeanchampemont/notedown/note/persistence/Note.java
// @Entity
// @Table(name = "note")
// public class Note {
//     @Id
//     @Type(type = "uuid-char")
//     private UUID id;
// 
//     @Column(name = "title", length = 64, nullable = false)
//     private String title;
// 
//     @Column(name = "content", nullable = false)
//     @Lob
//     @Type(type = "org.hibernate.type.StringClobType")
//     private String content;
// 
//     @Column(name = "last_modification", nullable = false)
//     @Temporal(TemporalType.TIMESTAMP)
//     private Date lastModification;
// 
//     @ManyToOne(fetch = FetchType.EAGER)
//     @JoinColumn(name = "user_id", nullable = false)
//     private User user;
// 
//     @OneToMany(mappedBy = "note", cascade = CascadeType.REMOVE)
//     @OrderBy("version DESC")
//     private List<NoteEvent> events = new ArrayList<>();
// 
//     public Note() {
//         id = UUID.randomUUID();
//     }
// 
//     public Note(String title, String content, User user) {
//         id = UUID.randomUUID();
//         this.title = title;
//         this.content = content;
//         this.user = user;
//     }
// 
//     public UUID getId() {
//         return id;
//     }
// 
//     public void setId(UUID id) {
//         this.id = id;
//     }
// 
//     public String getTitle() {
//         return title;
//     }
// 
//     public void setTitle(String title) {
//         this.title = title;
//     }
// 
//     public String getContent() {
//         return content;
//     }
// 
//     public void setContent(String content) {
//         this.content = content;
//     }
// 
//     public Date getLastModification() {
//         return lastModification;
//     }
// 
//     public void setLastModification(Date lastModification) {
//         this.lastModification = lastModification;
//     }
// 
//     public User getUser() {
//         return user;
//     }
// 
//     public void setUser(User user) {
//         this.user = user;
//     }
// 
//     public List<NoteEvent> getEvents() {
//         return events;
//     }
// 
//     public void setEvents(List<NoteEvent> events) {
//         this.events = events;
//     }
// 
//     @Transient
//     public Long getFirstAvailableVersion() {
//         if (events == null || events.size() == 0) {
//             return 0L;
//         } else {
//             return events.get(events.size() - 1).getId().getVersion();
//         }
//     }
// 
//     @Transient
//     public Long getLastVersion() {
//         if (events == null || events.size() == 0) {
//             return 0L;
//         } else {
//             return events.get(0).getId().getVersion();
//         }
//     }
// }


// Path: src/main/java/com/jeanchampemont/notedown/user/persistence/User.java
import com.jeanchampemont.notedown.note.persistence.Note;
import javax.persistence.*;
import java.util.HashSet;
import java.util.Set;

/*
 * Copyright (C) 2014, 2015 NoteDown
 *
 * This file is part of the NoteDown project.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *  http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.jeanchampemont.notedown.user.persistence;



@Entity
@Table(name = "user_account")
public class User {
    @Id
    @GeneratedValue(strategy = GenerationType.TABLE)
    private long id;

    @Column(name = "email", unique = true, length = 64)
    private String email;

    @Column(name = "password", length = 60)
    private String password;

    @OneToMany(fetch = FetchType.LAZY, mappedBy = "user")
    private Set<Note> notes = new HashSet<>();