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