Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.help > #1553
| Date | Tue, 07 Feb 2012 10:21:42 +0100 |
|---|---|
| From | Short <lamia@mail.com> |
| User-Agent | Mozilla/5.0 (Windows NT 6.1; WOW64; rv:9.0) Gecko/20111222 Thunderbird/9.0.1 |
| MIME-Version | 1.0 |
| Newsgroups | comp.lang.java.help |
| Subject | JPA and composite primary key |
| Content-Type | text/plain; charset=ISO-8859-15; format=flowed |
| Content-Transfer-Encoding | 7bit |
| NNTP-Posting-Host | $$afwhll$slnyo.news.x-privat.org |
| Message-ID | <4f30ed2a$1@news.x-privat.org> (permalink) |
| Organization | X-Privat.Org NNTP Server - http://www.x-privat.org |
| Lines | 55 |
| X-Authenticated-User | $$p9zou1n1$ng5dhdq$s2 |
| X-Complaints-To | abuse@x-privat.org |
| Path | csiph.com!x330-a1.tempe.blueboxinc.net!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!newsfeed.x-privat.org!x-privat.org!not-for-mail |
| Xref | x330-a1.tempe.blueboxinc.net comp.lang.java.help:1553 |
Show key headers only | View raw
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