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: Compound key, joined subclasses, error: no logical column
PostPosted: Wed Jul 09, 2008 4:49 pm 
Beginner
Beginner

Joined: Fri Aug 05, 2005 3:36 am
Posts: 28
Hey folks - I get the following exception with my new mapping.

Code:
org.hibernate.MappingException: Unable to find column with logical name: CLIENT_ID in org.hibernate.mapping.Table(CONFIGURABLE_OBJECT_VW) and its related supertables and secondary tables

I'm using annotations. I have an abstract base class mapped like this:

Code:
@Entity
@Inheritance(strategy=InheritanceType.JOINED)
@IdClass(ExoticKey.class)
@Table(name="CONFIGURABLE_OBJECT_VW")
@DiscriminatorColumn(name="DISCRIMINATOR")
public abstract class PropertyTarget {
   
   @Id @Column(name="CLIENT_ID")
   private Long clientId;
   @Id @Column(name="SKILL_ID")
   private Long skillId;

        // this is for convenience...
   public ExoticKey getId() {
      return new ExoticKey(this);
   }
   


My key class looks like this:

Code:
@Embeddable
public class ExoticKey implements Serializable {

   /**
    *
    */
   private static final long serialVersionUID = -819374448198389297L;
   private Long clientId;
   private Long skillId;

   public ExoticKey(Long clientId, Long skillId) {
      this.clientId = clientId;
      this.skillId = skillId;
      
   }
   public ExoticKey(PropertyTarget propertyTarget) {
      this.clientId = propertyTarget.getClientId();
      this.skillId = propertyTarget.getSkillId();
   }

   public Long getClientId() {
      return clientId;
   }
   
   public Long getSkillId() {
      return skillId;
   }
   
}

I don't think the subclass mappings are involved in the problem, but one looks like this:

Code:
@Entity
@Table(name="SKILL_VW")
public class Skill extends PropertyTarget {
...
}


Here's the stack trace:

Code:
org.hibernate.MappingException: Unable to find column with logical name: CLIENT_ID in org.hibernate.mapping.Table(CONFIGURABLE_OBJECT_VW) and its related supertables and secondary tables
   at org.hibernate.cfg.Ejb3JoinColumn.checkReferencedColumnsType(Ejb3JoinColumn.java:395)
   at org.hibernate.cfg.BinderHelper.createSyntheticPropertyReference(BinderHelper.java:102)
   at org.hibernate.cfg.ToOneFkSecondPass.doSecondPass(ToOneFkSecondPass.java:88)
   at org.hibernate.cfg.AnnotationConfiguration.processFkSecondPassInOrder(AnnotationConfiguration.java:494)
   at org.hibernate.cfg.AnnotationConfiguration.secondPassCompile(AnnotationConfiguration.java:299)
   at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1292)
   at org.hibernate.cfg.AnnotationConfiguration.buildSessionFactory(AnnotationConfiguration.java:854)
   at com.livevox.config.inputfilter.Configuration.initializeServices(Configuration.java:101)
   at com.livevox.config.inputfilter.FilterConfigDAOTest.setUp(FilterConfigDAOTest.java:23)
   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
   at java.lang.reflect.Method.invoke(Method.java:597)
   at org.junit.internal.runners.BeforeAndAfterRunner.invokeMethod(BeforeAndAfterRunner.java:74)
   at org.junit.internal.runners.BeforeAndAfterRunner.runBefores(BeforeAndAfterRunner.java:50)
   at org.junit.internal.runners.BeforeAndAfterRunner.runProtected(BeforeAndAfterRunner.java:33)
   at org.junit.internal.runners.TestMethodRunner.runMethod(TestMethodRunner.java:75)
   at org.junit.internal.runners.TestMethodRunner.run(TestMethodRunner.java:45)
   at org.junit.internal.runners.TestClassMethodsRunner.invokeTestMethod(TestClassMethodsRunner.java:66)
   at org.junit.internal.runners.TestClassMethodsRunner.run(TestClassMethodsRunner.java:35)
   at org.junit.internal.runners.TestClassRunner$1.runUnprotected(TestClassRunner.java:42)
   at org.junit.internal.runners.BeforeAndAfterRunner.runProtected(BeforeAndAfterRunner.java:34)
   at org.junit.internal.runners.TestClassRunner.run(TestClassRunner.java:52)
   at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:45)
   at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
   at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
   at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
   at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
   at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)



I don't think the physical tables matter at this point, right?

Help appreciated.

Larry Edelstein
Principal Software Engineer
Livevox
ribs@acm.org


Top
 Profile  
 
 Post subject: Update
PostPosted: Wed Jul 09, 2008 11:45 pm 
Beginner
Beginner

Joined: Fri Aug 05, 2005 3:36 am
Posts: 28
I've mostly gotten around the problem by using @EmbeddedID instead of @IdClass (and consequently by embedding the key class in the object.

Now I have a couple of problems. The situation is that I'm mapping a really screwed up legacy database. Even with views, it's pretty strange-o. What I need to do is allow one of the primary key fields to be NULL at times.

I could explain more, but if I can avoid it, I will :-)

My issues are that:

- when I generate the schema, for testing, it always makes both PK fields non-null. How can I disable that eminently sensible but yet in-this-case-undesirable behavior?

- I intend to compare NULLs to NULLs. That doesn't work. What am I thinking? What will I do?


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.