-->
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.  [ 3 posts ] 
Author Message
 Post subject: JoinTable, mixed case table name not quoted properly
PostPosted: Tue Jan 18, 2011 11:16 am 
Newbie

Joined: Wed Mar 28, 2007 4:00 pm
Posts: 7
I've been blessed with a Postgres DB with mixed case table names.

Normally, back ticks (`) can be added when a mixed case table name is needed, i.e. name="`mixedCaseTableName`"

If I use back ticks in @JoinTable, like this

Code:
@ManyToOne(fetch = FetchType.LAZY)
@JoinTable(name = "`xref_employee_number_Contact`", schema="public",
         joinColumns = @JoinColumn(name = "employee_number"),
         inverseJoinColumns = @JoinColumn(name = "`CONT_ContactID`"))
public ContContact getContContact() {
    return contContact;
}


then I receive the following error.

org.hibernate.AnnotationException: Cannot find the expected secondary table: no xref_employee_number_Contact available for com.ro.domain.entity.EmployeeDept

If no back ticks are included in @JoinTable, like this
Code:
@ManyToOne(fetch = FetchType.LAZY)
@JoinTable(name = "xref_employee_number_Contact", schema="public",
         joinColumns = @JoinColumn(name = "employee_number"),
         inverseJoinColumns = @JoinColumn(name = "`CONT_ContactID`"))
public ContContact getContContact() {
    return contContact;
}


then my generated sql looks like this. It doesn't work because xref_employee_number_Contact should be quoted.

Code:
   select
        this_."ID" as ID1_7_13_,
        this_."CONT_PersonID" as CONT2_7_13_,
        this_."CONT_val_ContactRoleID" as CONT3_7_13_,
        this_.crm_individual_id as crm4_7_13_,
        this_.crm_userid as crm5_7_13_,
        this_1_.employee_number as employee0_6_13_
    from
        public."CONT_Contact" this_
    left outer join
        xref_employee_number_Contact this_1_  on this_."ID"=this_1_."CONT_ContactID"
    where
        this_."ID"=60



I'm using Hibernate 3.6.0.Final

Are there any workarounds so the table name will be quoted in the sql? Thanks for your help.


Top
 Profile  
 
 Post subject: Re: JoinTable, mixed case table name not quoted properly
PostPosted: Tue Jan 18, 2011 12:20 pm 
Beginner
Beginner

Joined: Tue Oct 26, 2010 6:12 pm
Posts: 29
I don't have access to Postgres right now, so cannot say for sure. But can you try with the work-around mentioned in this bug?


Top
 Profile  
 
 Post subject: Re: JoinTable, mixed case table name not quoted properly
PostPosted: Tue Jan 18, 2011 1:19 pm 
Newbie

Joined: Wed Mar 28, 2007 4:00 pm
Posts: 7
I used that approach for reverse engineering. Thanks.

My workaround is to create an entity for the join table. Using @JoinTable would have been more efficient. Other suggestions are still welcomed.


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