Folks,
I have the following code;
@Enitity
| public class Cruise
| {
| private Collection<Reservation> reservations;
| ...
| @OneToMany(cascade = CascadeType.ALL, mappedBy="cartridge")
| public Collection<Reservation> getReservations() {
| return reservations;
| }
|
| public void setReservations(Collection<Reservation>
reservations) {
| this.reservations= reservations;
| }
| ...
| }
|
| @Enitity
| public class Reservation
| {
| private Cruise cruise;
| ...
| @ManyToOne(cascade = {CascadeType.ALL})
| @JoinColumn(name="cruiseId", nullable=true)
| public Cruise getCruise() {
| return cruise ;
| }
|
| public void setCruise(Cruise cruise ) {
| this.cruise = cruise;
| }
| ...
| }
|
| @Stateless
| public class PersistBean
| {
|
| /** Injected EntityManger */
| @PersistenceContext( unitName="eg")
| protected EntityManager em = null;
|
| ...
|
| public void persist( Set reservations, Curise cruise )
| {
| .....
| Iterator it = reservations.iterator();
| while( it.hasNext() )
| {
| Reservation r = (Reservation)it.next();
| r.setCruise( cruise );
| em.persist( r );
| }
| ......
| }
|
| ....
| }
Now, I'm trying to write just 4 reservations. And, on the 4th one I get a db
error about a contraint being voilated! I find that the first 3 records are
writen to the Reservation table.
My point is that, if my persist() method is running in a transaction, which I
believe it is, then the first 3 records should have been rolledback, following
an error on the 4th record!!!!
Please help! Any help will be appreciated. Thx in adv!
View the original post :
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4070762#4070762
Reply to the post :
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4070762
_______________________________________________
jboss-user mailing list
[email protected]
https://lists.jboss.org/mailman/listinfo/jboss-user