-->
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: wrong SQL order in using hibernate with JRun
PostPosted: Mon Jan 29, 2007 8:21 am 
Newbie

Joined: Fri Dec 01, 2006 6:05 am
Posts: 1
Hi All,
I've encountered a problem of wrong SQL order in an environment using hibernate and JRun:

- hibernate 3.2.2
- JRun4
- spring 2.0.2


I have entities A and B, and there's an association between them
Code:
@Entity
@org.hibernate.annotations.Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
@Table(name = "TABLE_A")
public class A implements Serializable {
...
@OneToMany(fetch = FetchType.LAZY, mappedBy = "a", cascade = CascadeType.ALL)
public Set<B> getBs() {
    return bs;
}

public void setBs(Set<B> bs) {
    this.bs = bs;
}
...
}


Code:
@Entity
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
@Table(name = "VI_STB_T")
public class B implements Serializable {
...
private A a;
...
@ManyToOne(fetch = FetchType.LAZY)
@JoinTable(name = "ASSOCIATION", joinColumns = @JoinColumn(name = "B_ID", referencedColumnName = "ID"), inverseJoinColumns = @JoinColumn(name = "A_ID", referencedColumnName = "ID"))
public A getA() {
    return a;
}

public void setA(A a) {
    this.a = a;
}
...
}


Say I have an A containing a B. If I remove the B and add a second B, the generated SQL should be in this order after I merge A:
1. delete ASSOCIATION between A and first B
2. delete first B
3. insert second B
4. insert ASSOCIATION between A and second B

I can get the above expected result when using Tomcat 5.


But in Jrun, the SQLs are reversed: 3->4->1->2
This should not bring up any problem if B has no unique constraint.

Unluckily, I've got a unique constraint in B in my case. If I perform the above operation and the unique key of first and second B are the same, I'll get an Exception of violating the unique constraint.

Anyone can help me?
Thank you very much.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Feb 02, 2007 5:08 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
I don't see how the code could be different when run inside JRun, I doubt their DS reorder the statements :-)

_________________
Emmanuel


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.