-->
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.  [ 6 posts ] 
Author Message
 Post subject: SecondaryTable with quoted PrimaryKeyJoinColumn
PostPosted: Tue Dec 18, 2007 1:54 pm 
Newbie

Joined: Tue Dec 18, 2007 1:40 pm
Posts: 6
I've got an odd problem trying to map a secondary table. The mapping works unquoted.

I'm using Hibernate 3.2.5.ga and Annotations 3.3.0.ga.

Code:
@Entity
@Table(name = "`POLICIES`")
@SecondaryTable(name = "`POLICY_DIAGRAMS`", pkJoinColumns=@PrimaryKeyJoinColumn(name="`UniqueID`", referencedColumnName="`UniqueID`"))
public class Policy implements Serializable {

   @Id
   @Column(name = "`UniqueID`")
   private String id;
...


The exception I'm getting is:
Code:
org.hibernate.MappingException: Unable to find logical column name from physical name UniqueID in table POLICIES
        at org.hibernate.cfg.Mappings.getLogicalColumnName(Mappings.java:521)
        at org.hibernate.cfg.Ejb3JoinColumn.buildJoinColumn(Ejb3JoinColumn.java:211)
        at org.hibernate.cfg.annotations.EntityBinder.createPrimaryColumnsToSecondaryTable(EntityBinder.java:483)
        at org.hibernate.cfg.annotations.EntityBinder.finalSecondaryTableBinding(EntityBinder.java:440)
        at org.hibernate.cfg.AnnotationBinder.bindClass(AnnotationBinder.java:770)
        at org.hibernate.cfg.AnnotationConfiguration.processArtifactsOfType(AnnotationConfiguration.java:498)
        at org.hibernate.cfg.AnnotationConfiguration.secondPassCompile(AnnotationConfiguration.java:277)
        at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1286)
        at org.hibernate.cfg.AnnotationConfiguration.buildSessionFactory(AnnotationConfiguration.java:915)


I did some poking around inside Hibernate and it looks like the column it's trying to map has the backticks in the Mappings.ColumnNames.physicalToLogical map but the field being requested doesn't have the back ticks.

Code:
Searching binding for: UniqueID  on Table: POLICIES
Key: `UniqueID`    Value:`UniqueID`


Did I just map this wrong?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Dec 18, 2007 6:12 pm 
Newbie

Joined: Tue Dec 18, 2007 1:40 pm
Posts: 6
After some digging I tried using a NamingStrategy to get around this. That blows up as well. I did however find that in org.hibernate.mapping.Column that if there is a back tick or an escape of the dialect in use it is stripped and a boolean (quoted) is set. The org.hibernate.cfg.Mappings class stores the name value with theses characters in them as both logical and physical. org.hibernate.cfg.Ejb3JoinColumn seems to trip over this on line 213 when building the join columns for SecondaryTables.

This seems to be a bug but I am unsure how to best fix the issue as org.hibernate.mapping.Column discards the characters that it found in the name even though org.hibernate.cfg.Mappings is keeping them.

Any ideas?


Top
 Profile  
 
 Post subject:
PostPosted: Sat Dec 22, 2007 5:19 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
No the fix should only affect Hibernate annotations, I don't see a reason to change Hibernate Core on that
Open a JIRa issue with a minimal failing test case, if possible with a patch :) so that we can track progress on that.

_________________
Emmanuel


Top
 Profile  
 
 Post subject: did you file a bug report?
PostPosted: Tue Mar 25, 2008 10:10 am 
Newbie

Joined: Tue Mar 25, 2008 10:07 am
Posts: 3
Did you file a bug report? Can you post a link to the JIRA page?

_________________
Bastian Voigt
Hamburg, Germany


Top
 Profile  
 
 Post subject: did you file a bug report?
PostPosted: Tue Mar 25, 2008 10:11 am 
Newbie

Joined: Tue Mar 25, 2008 10:07 am
Posts: 3
Did you file a bug report? Can you post a link to the JIRA page?
(sorry for duplication)

_________________
Bastian Voigt
Hamburg, Germany


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 25, 2008 12:04 pm 
Newbie

Joined: Tue Mar 25, 2008 10:07 am
Posts: 3
I have now posted a bug report:

http://opensource.atlassian.com/projects/hibernate/browse/ANN-718

_________________
Bastian Voigt
Hamburg, Germany


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 6 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.