-->
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: MappingException: Unable to find column with logical name
PostPosted: Fri Aug 13, 2010 2:09 pm 
Beginner
Beginner

Joined: Thu May 20, 2010 12:31 pm
Posts: 28
Hello,

I get an exception with the following entity bean:

Code:
@Entity
@Table(name = "ZipAreas")
public class ZipArea implements Serializable
{
   @EmbeddedId
   private ZipAreaId id;

   @ManyToOne
   @PrimaryKeyJoinColumns(value = {@PrimaryKeyJoinColumn(name = "country_code", referencedColumnName = "country_code"), @PrimaryKeyJoinColumn(name = "zip_code", referencedColumnName = "code")})
   private Zip zip = null;

   @ManyToOne
   @PrimaryKeyJoinColumns(value = {@PrimaryKeyJoinColumn(name = "country_code", referencedColumnName = "country_code"), @PrimaryKeyJoinColumn(name = "state_code", referencedColumnName = "state_code"), @PrimaryKeyJoinColumn(name = "city_name", referencedColumnName = "name")})
   private City city = null;

   @OneToMany(targetEntity = PostAddress.class, mappedBy = "postAddresses")
   private Set<PostAddress> postAddresses = new HashSet<PostAddress>();

        ...


The DB design can be viewed here:

http://www.kawoolutions.com/media/geo-info.png

The stack trace is:

Code:
org.hibernate.MappingException: Unable to find column with logical name: state_code in ZipAreas
   org.hibernate.cfg.Ejb3JoinColumn.checkReferencedColumnsType(Ejb3JoinColumn.java:419)
   org.hibernate.cfg.BinderHelper.createSyntheticPropertyReference(BinderHelper.java:102)
   org.hibernate.cfg.ToOneFkSecondPass.doSecondPass(ToOneFkSecondPass.java:88)
   org.hibernate.cfg.AnnotationConfiguration.processEndOfQueue(AnnotationConfiguration.java:456)
   org.hibernate.cfg.AnnotationConfiguration.processFkSecondPassInOrder(AnnotationConfiguration.java:438)
   org.hibernate.cfg.AnnotationConfiguration.secondPassCompile(AnnotationConfiguration.java:309)
   org.hibernate.cfg.Configuration.buildMappings(Configuration.java:1148)
   org.hibernate.ejb.Ejb3Configuration.buildMappings(Ejb3Configuration.java:1226)
   org.hibernate.ejb.EventListenerConfigurator.configure(EventListenerConfigurator.java:173)
   org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:854)
   org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:191)
   org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:253)
   org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(HibernatePersistence.java:125)
   javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:52)
   javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:34)
   com.kawoolutions.bbstats.servlet.BasketballStatsServlet.doGet(BasketballStatsServlet.java:67)
   javax.servlet.http.HttpServlet.service(HttpServlet.java:690)
   javax.servlet.http.HttpServlet.service(HttpServlet.java:803)


Googling revealed:

http://opensource.atlassian.com/project ... e/HHH-2872
and the related issue
http://opensource.atlassian.com/project ... se/ANN-590

After reading this I'm still puzzled. What's happening? Is the code wrong? BTW I'm using Java EE 5 and the code is supposed to be JPA 1.0 compatible.

Can anyone help?

Karsten

PS: How do I find my Hibernate version when org.hibernate.Version doesn't yet exist?


Top
 Profile  
 
 Post subject: Re: MappingException: Unable to find column with logical name
PostPosted: Wed Mar 16, 2011 12:03 pm 
Beginner
Beginner

Joined: Thu May 20, 2010 12:31 pm
Posts: 28
It's a rather old posting, but the solution is not obvious. There are two issues here:

1. When declaring @JoinColumns or @PrimaryKeyJoinColumns you must specify all column names. See http://download.oracle.com/javaee/6/api ... lumns.html

2. Hibernate has an unresolved issue (as of 2011-03) with using @PrimaryKeyJoinColumns in mappings. See http://opensource.atlassian.com/project ... e/HHH-5741

Karsten


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:
cron
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.