Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.help > #1553
| Date | 2012-02-07 10:21 +0100 |
|---|---|
| From | Short <lamia@mail.com> |
| Newsgroups | comp.lang.java.help |
| Subject | JPA and composite primary key |
| Message-ID | <4f30ed2a$1@news.x-privat.org> (permalink) |
| Organization | X-Privat.Org NNTP Server - http://www.x-privat.org |
Hi.
Here's the scenario:
An abstract class that defines an Id "generated":
public abstract Class1{
[...]
@Column(name = "ID")
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator =
"IdSequenceGen")
@Id
public Long getId()
{
return this.id;
}
[...]
}
An entity Class, extending Class1, that has a composite PK: The 'Class1'
ID and a second field:
@Entity
@IdClass(Class2.class)
@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
@SequenceGenerator(name = "IdSequenceGen", sequenceName = "SQ_CLASS2")
@Table(name = "CIM_PERSON_DEMOGRAPHIC")
public class Class2 extends Class1{
private Integer prog = 0;
@Column(name = "PROG")
@Id
public Integer getProg()
{
return prog;
}
[...]
}
But in this case I've this error at runtime:
javax.persistence.PersistenceException: [PersistenceUnit: datamodel]
Unable to configure EntityManagerFactory
at
org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:375)
at
org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(HibernatePersistence.java:56)
at
javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:48)
at
javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:32)
at
com.noemalife.platform.dm.test.AbstractTest.buildEntityManager(AbstractTest.java:111)
Caused by: org.hibernate.AnnotationException: Unknown Id.generator:
IdSequenceGen
How can i solve this problem?
Thank you so much
Back to comp.lang.java.help | Previous | Next — Next in thread | Find similar | Unroll thread
JPA and composite primary key Short <lamia@mail.com> - 2012-02-07 10:21 +0100 Re: JPA and composite primary key Lew <lewbloch@gmail.com> - 2012-02-07 10:45 -0800
csiph-web