-->
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: createAlias - error if two tables have the same column name
PostPosted: Tue Mar 02, 2010 10:13 pm 
Newbie

Joined: Tue Mar 02, 2010 10:01 pm
Posts: 2
Hi,

Two classes below each with a member variable called "snap".

public class Class1 {
private Long id;
private Class2 class2;
private Boolean snap;
.
.

public class Class2 {
private Long id;
private Boolean snap;
private Integer blah;
.
.

Now if I run this code....
Criteria crit = hibernateSession.createCriteria(Class1.class);
crit.createAlias("class2","class2Alias").add(Restrictions.eq("class2Alias.blah", 10));

...Tomcat generates this error:
ERROR JDBCExceptionReporter:78 - Duplicate key or integrity constraint violation message from server: "Column 'snap' in where clause is ambiguous"


Does anyone know how to fix this without resorting to renaming the "snap" member variable in one of the classes?

Thanks.


Top
 Profile  
 
 Post subject: Re: createAlias - error if two tables have the same column name
PostPosted: Wed Mar 03, 2010 10:41 am 
Newbie

Joined: Tue Mar 02, 2010 10:01 pm
Posts: 2
I'm using native SQL query as a workaround instead of createAlias (but it makes the code look ugly). Would be still nice to use createAlias if anyone has any ideas?


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.