Reputation: 151
I have a class Customer which is an entity: @Entity
public class Customer {
@Id
@GeneratedValue(strategy=GenerationType.SEQUENCE,generator="customerId_Sequence")
@SequenceGenerator(name="customerId_Sequence",sequenceName="CUSTOMER_SEQ",allocationSize=1)
private long customerId;
private String firstName;
private String lastName;
private BillingDetails billingDetails
I have a class BillingDetails that looks like this:
public class BillingDetails {
private String type;
private long ccNumber;
I use hibernate as my persistence provider. I want it to create just one table in sql, which have columns customerId, firstName, lastName, type, ccNumber. I want it all in one table, I don't want billing details to be an entity. Is this possible?
When I try like this I get an error: Could not determine type for: ****.BillingDetails
Upvotes: 0
Views: 480
Reputation: 2268
Model BillingDetails as @Embeddable.
@Entity
public class Customer {
@Id
@GeneratedValue(strategy=GenerationType.SEQUENCE,generator="customerId_Sequence")
@SequenceGenerator(name="customerId_Sequence",sequenceName="CUSTOMER_SEQ",allocationSize=1)
private long customerId;
private String firstName;
private String lastName;
@Embedded
private BillingDetails billingDetails;
...
}
@Embeddable
public class BillingDetails {
private String type;
private long ccNumber;
...
}
Upvotes: 2