-->
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.  [ 1 post ] 
Author Message
 Post subject: order of @JoinColumn annotations seems to matter
PostPosted: Thu Mar 12, 2009 4:45 pm 
Newbie

Joined: Thu Mar 12, 2009 4:29 pm
Posts: 1
I spent some time looking over the documentation and couldn't find anything about this.

I have the following code:

Code:
@OneToMany(fetch=FetchType.LAZY)
    @JoinColumns({
        @JoinColumn(name="reasonID"),
        @JoinColumn(name="scannerID")})
    public Set<ExceptionRouting> routing = new HashSet<ExceptionRouting>();


(The primary key on ExceptionRouting is actually three keys, reasonID, scannerID and divertID, if that matters.)

That seems to work. However, if I change the ordering of the @JoinColumn mappings, it doesn't work. It *runs*, but the results are wrong.

I'm using SQL Server 2005, so I load up the profiler and look at the SQL that is actually being ran, which is somewhat different than what Hibernate prints out in debug. At the very end of the SQL statement, I'll see this:

Code:
... where routing0_.reasonID=@P0 and routing0_.scannerID=@P1',16,1


Those last two numbers are the parameters that get set. Now, if I change the order of the annotations this is what I see:

Code:
... where routing0_.scannerID=@P0 and routing0_.reasonID=@P1',16,1


The column names are swapped, but the actual argument values are not! Is this by design? Is this a bug in Hibernate, or is this a bug in the SQL Server JDBC driver?

If anyone thinks this is a bug, let me know and I'll try to figure out a patch if I can. Thanks!

John


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

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.