-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: Problem with composite primary keys
PostPosted: Fri Jul 18, 2008 3:12 am 
Newbie

Joined: Thu Jul 17, 2008 7:49 am
Posts: 5
Hibernate version: Hibernate 3 (JBoss 4.2.2GA)

Full stack trace of any exception that occurs:


Quote:
13:41:02,490 WARN [ServiceController] Problem starting service persistence.units:ear=Projekt.ear,jar=ProjektEJB.jar,unitName=projekt03
org.hibernate.AnnotationException: Column name manrSuffix of xx.Mitarb not found in JoinColumns.referencedColumnName
at org.hibernate.cfg.annotations.TableBinder.bindFk(TableBinder.java:306)
at org.hibernate.cfg.FkSecondPass.doSecondPass(FkSecondPass.java:64)
at org.hibernate.cfg.AnnotationConfiguration.processFkSecondPassInOrder(AnnotationConfiguration.java:428)
at org.hibernate.cfg.AnnotationConfiguration.secondPassCompile(AnnotationConfiguration.java:286)
at org.hibernate.cfg.Configuration.buildMappings(Configuration.java:1115)
at org.hibernate.ejb.Ejb3Configuration.buildMappings(Ejb3Configuration.java:1233)
at org.hibernate.ejb.EventListenerConfigurator.configure(EventListenerConfigurator.java:154)
at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:869)
at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:407)
at org.hibernate.ejb.HibernatePersistence.createContainerEntityManagerFactory(HibernatePersistence.java:126)
at org.jboss.ejb3.entity.PersistenceUnitDeployment.start(PersistenceUnitDeployment.java:246)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.jboss.ejb3.ServiceDelegateWrapper.startService(ServiceDelegateWrapper.java:103)
at org.jboss.system.ServiceMBeanSupport.jbossInternalStart(ServiceMBeanSupport.java:289)
at org.jboss.system.ServiceMBeanSupport.jbossInternalLifecycle(ServiceMBeanSupport.java:245)


Name and version of the database you are using: Oracle8i

Can anybody point out whats wrong with my code? I dont get it, I've tried some many variants of the JoinColumn annotation now. Also I tried using EmbeddedId (my cfg files are empty, I'm just using annotations)

Code:
@Embeddable
public class MitarbPK implements Serializable {
   @Column(name="MANR", insertable=false, updatable=false)
   private Mitarbstamm manr;

   @Column(name="MANR_SUFFIX")
        // ich hab hier schon vieles als ausprobiert ...
   private int manrSuffix;


Code:
@Entity
@IdClass(MitarbPK.class)
public class Mitarb implements Serializable {
   

   @Id
   @Column(name="MANR")
   private Mitarbstamm manr;   
   
   @Id
   @Column(name="MANR_SUFFIX")
   private int manrSuffix;   


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jul 20, 2008 8:20 am 
Newbie

Joined: Sat Jul 12, 2008 4:25 am
Posts: 8
Hi,

From my understanding of the JPA spec: if your primary key is annotated with @Embeddable, you have to use @EmbeddedId instead of @IdClass.

Hope this helps,
Matt


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.