Reputation: 3803
I have my super abstract class :
@Entity
@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
public abstract class User {
@Id
public int id;
public String name;
}
And two other classes extends User:
Customer
@Entity
@Table(name = "customers")
public class Customer extends User{
@Id
public int id;
public String role;
public Customer(String role){
super();
this.role = role;
}
}
Seller
@Entity
@Table(name = "sellers")
public class Seller extends User{
@Id
@GeneratedValue
public int id;
public String role; // Seller
public Seller(String role){
super();
this.role = role;
}
}
I would like to be able to use the save() method in play, so I wrote this :
public static Result saveCustomer(){
Customer customer = Form.form(Customer.class).bindFromRequest().get();
customer.save();
return ok();
}
But, save() is not defined.
What would be the way to solve this issue ?
Upvotes: 1
Views: 328
Reputation: 312
Actually... to get the entityManager in play 2.x you hava a Helper.
JPA.em().persist(object);
you can see more information in this link.
Upvotes: 1
Reputation: 4463
save()
method is a part of GenericModel
which belongs to Play 1.x
. Since, you use Play 2.x
you should use JPA
object and entityManager.persist()
method.
Upvotes: 0