package ttu.tteh.user;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.OneToOne;

import lombok.Getter;
import lombok.Setter;

@Entity
@Getter
@Setter
public class User {
	@Id
	@GeneratedValue
	long id;
	String firstName;
	String lastName;
	int numOfPets;
	@OneToOne(cascade=CascadeType.ALL)
	Car car;
}

package ttu.tteh.user;

import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.OneToOne;

import lombok.Getter;
import lombok.Setter;

@Entity
@Getter
@Setter
public class User {
	@Id
	@GeneratedValue
	long id;
	String firstName;
	String lastName;
	int numOfPets;
	@OneToOne()
	Car car;
}

--- 
+++ 
@@ -1,5 +1,6 @@
 package ttu.tteh.user;
 
+import javax.persistence.CascadeType;
 import javax.persistence.Entity;
 import javax.persistence.GeneratedValue;
 import javax.persistence.Id;
@@ -18,6 +19,6 @@
 	String firstName;
 	String lastName;
 	int numOfPets;
-	@OneToOne()
+	@OneToOne(cascade=CascadeType.ALL)
 	Car car;
 }
Save related objects automatically using CascadeType

