package it.unical.asde.hibernate_first_example.model;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;


@Entity
@Table(name = "book")
public class Book {

	@Id
	@Column
	@GeneratedValue(strategy = GenerationType.AUTO)
	private int id;

	@Column(name = "title", nullable = false, unique = true)
	private String title;

	@ManyToOne(cascade={CascadeType.PERSIST})
	@JoinColumn(nullable = false)
	private Author author;

	@Column(nullable = false)
	private String editor;
	
	public Book() {
		super();
	}

	public Book(String title, Author author, String editor) {
		super();
		this.title = title;
		this.author = author;
		this.editor = editor;
	}

	public String getTitle() {
		return title;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	public Author getAuthor() {
		return author;
	}

	public void setAuthor(Author author) {
		this.author = author;
	}

	public String getEditor() {
		return editor;
	}

	public void setEditor(String editor) {
		this.editor = editor;
	}

	public synchronized int getId() {
		return id;
	}

	public synchronized void setId(int id) {
		this.id = id;
	}
	
	

}

@@ -52,46 +52,8 @@
 l;%0A%0A
-import javax.persistence.CascadeType;%0A
 impo
@@ -73,32 +73,32 @@
 istence.Column;%0A
+
 import javax.per
@@ -331,16 +331,106 @@
 Table;%0A%0A
+import org.hibernate.annotations.Cascade;%0Aimport org.hibernate.annotations.CascadeType;%0A%0A%0A
 %0A@Entity
@@ -651,18 +651,25 @@
 oOne
-(c
+%0A%09@C
 ascade
+(value
 =
-%7B
 Casc
@@ -680,16 +680,19 @@
 ype.
-PERSIST%7D
+SAVE_UPDATE
 )%0A%09@

Fix cascade