-->
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: help!! :( About @IdClass: Same logical column name reference
PostPosted: Wed May 07, 2008 10:53 pm 
Newbie

Joined: Wed May 07, 2008 10:23 pm
Posts: 2
When i using @IdClass to get composite Key ,i meet a org.hibernate.MappingException with message of "Same logical column name referenced by different physical ones :TB_Ticket.movie => 'id.movie' and '_identifierMapper.movie'"
my code is below. I seached in google,no one record about that,someone can help me? thanks a lot.
my hibernate is "3.2.0.CR2" and my annotation is "3.2.0 CR1"

1.domain Class:Ticket.java
Code:
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.IdClass;

@Entity
@IdClass(TicketPk.class)
public class Ticket {
   @Id
   private String movie;
   @Id
   private String time;
   
   private String elseAtt;

   ..setter and getter..
}


2.pk Class:TicketPk.java

Code:
import java.io.Serializable;
import javax.persistence.Embeddable;@Embeddable
@Embeddable
public class TicketPk implements Serializable {
   private String movie;
   private String time;
   ..getter and setter and Serializable implements..
}


3.main Class:TestManyToOne.java
Code:
import org.hibernate.SessionFactory;
import org.hibernate.cfg.AnnotationConfiguration;

public class TestManyToOne {

   public static void main(String[] args ) {

      AnnotationConfiguration config = new AnnotationConfiguration();
      config.addAnnotatedClass(Ticket.class); 
   
      config.setNamingStrategy(new com.projectEvaluation.dao.hbImp.TNamingStrategy());
      SessionFactory sessionFactory = config.configure("./hibernate.cfg.xml").buildSessionFactory();

   }
}


when I run it as JavaApplication ,i meet that Exception ,
Code:
Exception in thread "main" org.hibernate.MappingException: Same logical column name referenced by different physical ones: TB_Ticket.movie => 'id.movie' and '_identifierMapper.movie'
   at org.hibernate.cfg.Mappings.addColumnBinding(Mappings.java:474)
   at org.hibernate.cfg.Ejb3Column.addColumnBinding(Ejb3Column.java:259)
   at org.hibernate.cfg.Ejb3Column.linkWithValue(Ejb3Column.java:251)
   at org.hibernate.cfg.annotations.SimpleValueBinder.fillSimpleValue(SimpleValueBinder.java:237)
   at org.hibernate.cfg.annotations.SimpleValueBinder.make(SimpleValueBinder.java:218)
   at org.hibernate.cfg.annotations.PropertyBinder.bind(PropertyBinder.java:113)
   at org.hibernate.cfg.AnnotationBinder.processElementAnnotations(AnnotationBinder.java:1521)
   at org.hibernate.cfg.AnnotationBinder.fillComponent(AnnotationBinder.java:1646)
   at org.hibernate.cfg.AnnotationBinder.bindClass(AnnotationBinder.java:670)
   at org.hibernate.cfg.AnnotationConfiguration.processArtifactsOfType(AnnotationConfiguration.java:353)
   at org.hibernate.cfg.AnnotationConfiguration.secondPassCompile(AnnotationConfiguration.java:265)
   at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1205)
   at TestManyToOne.main(TestManyToOne.java:23)



I am puzzling...................Who can tell me>>>Thanks a lot a lot


Top
 Profile  
 
 Post subject: myself found the wrong
PostPosted: Wed May 07, 2008 11:44 pm 
Newbie

Joined: Wed May 07, 2008 10:23 pm
Posts: 2
my TNamingStrategy is wrong ,so meet that exception ,so foolish.thanks.


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.