-->
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: How to disable automatic increment of an entity's version
PostPosted: Tue Jan 23, 2007 4:30 am 
Newbie

Joined: Tue Dec 19, 2006 4:14 am
Posts: 8
Hi

I met a problem when I use Hibernate Annotation 3.2.1 GA.

A entity A is associated with many entity B. A and B are mapped by a parent-child relationship by the annotation.

I use the optimistic versioning or locking. But I donot want the entity A's version to be increased when an instance of B is added to or removed from the association.

How could I do it?

Thanks for your help.

The following is the annotation. I tried optimisticLock=OptimisticLockType.NONE, but it does not solve my issue.

Code:
@Entity
@org.hibernate.annotations.Entity( dynamicInsert=true, dynamicUpdate=true,
      optimisticLock=OptimisticLockType.NONE )
public class Conference implements java.io.Serializable {
    @Id
    private Long id;
   
    @Version
    @Column(name = "OBJ_VERSION")
    private int version;
   
    private long confId ;

    @OneToMany(mappedBy="conference", cascade={CascadeType.ALL}, fetch = FetchType.EAGER )
    @Cascade({org.hibernate.annotations.CascadeType.ALL, org.hibernate.annotations.CascadeType.DELETE_ORPHAN})
    @org.hibernate.annotations.MapKey(columns=@Column(name="legId"))
    private Map<Long, CallLeg> calls = new HashMap<Long, CallLeg>();
......
}

@Entity
@org.hibernate.annotations.Entity( dynamicInsert=true, dynamicUpdate=true,
      optimisticLock=OptimisticLockType.VERSION )
public class CallLeg implements java.io.Serializable {
    @Id
    private Long id;
   
    @Version
    @Column(name = "OBJ_VERSION")
    private int version;

    private Long legId ;
   
    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name="CONF_FK_ID")
    @org.hibernate.annotations.ForeignKey(name = "TO_CONF_FK")
    @Cascade(org.hibernate.annotations.CascadeType.SAVE_UPDATE)
    private Conference conference ;
......
}



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.