I want use custom class like ID
@javax.persistence.Embeddable
class ObjectID impements Serializable{
private Long value;
//setters, getters and other
}
Here is mapped class
@Entity
@IdClass(ObjectID.class)
public class Country implements Serializable
{
@Id
@AttributeOverride(name = "value", column = @Column(name = "id"))
@SequenceGenerator(name = "CountrySequenceGenerator",
sequenceName = "lab_country_seq")
@GeneratedValue(strategy = GenerationType.SEQUENCE,
generator = "CountryCountryGenerator")
private ObjectID value;
// setters, getters, fields
}
Doesn't work. Value wasn't generated. Any ideas, how can I generate ID for composite-id?
ID类必须是可序列化的,并实现hashCode和equals
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.