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.javaCode:
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.javaCode:
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