-->
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.  [ 6 posts ] 
Author Message
 Post subject: Many to One and Version Number of One Side
PostPosted: Tue Apr 11, 2006 2:45 am 
Regular
Regular

Joined: Tue Mar 23, 2004 2:10 am
Posts: 51
Hi,

I am using the following.
Hibernate version:3.2 CR1

Oracle 10g Release 2

This post may become a little longer but i request u to read it all and understand the scenerio.

I have two tables naming Service and ServiceType. Their relationship is Many to One from Service to ServiceType and One to Manay from Service Typeto Service.I am using Bi-Directional One to Many mapping for it where Service contains ServiceType and ServiceType contains the collection of Service.

My app is a webapp and it has a screen where u can create/update the Service entity. THis screen contains a lookup (or popup) for ServiceType entities. The popup open up a list of ServiceType for a user to select from and when he/she selects a service type a javascript function on the Service page is called which sets the value of Service Type name and its hidden primary key. THe problem comes when the user selects a value from poppup and on the Service page he/she saves the record. This things (by my web framework binding ) do the following it cretaes a New Object of ServiceType and sets its primary key to the selected value ( all of this is done in setter setServiceTypeId(Long serviceTypeId) in Service object). Now when i try to save the record an exception come saying TransientObjectException saying that ServiceType object is transient. No if i set the version number of the ServiceType object ( even incorrect version no) then it works fine. I cannot create a ServiceTpe object from popup and then set it to Service object as it is not possibe using javascript.
So i want to ask why hibernate sees the version number column of One side i thinks that only the exitense of Primary key should be enough to tell hibernate that the object is already persisted.

Just to summarize my problem again that When an object on Many side containg the refernce of One Side changes that reference (or create new ) where the One side object now only contains orimary key (of some already saved One object and its not possible to set all the values of One side object as it is popup or sth else) then why hibernate on saving many side record or update many side record says that the refernce of one side is transient and it works if version number of one side is set. Cannot only setting the primary key og one side should e enough to determine that it has already been saved. An d onething more that in all my tables i am using version number column for optimitic locking.

I hope that u have read it with patience and reply me asap.

Regards,
Shoaib Akhtar


Top
 Profile  
 
 Post subject:
PostPosted: Tue Apr 11, 2006 11:11 am 
Regular
Regular

Joined: Tue Mar 23, 2004 2:10 am
Posts: 51
Hi,
Still waiting fior reply. In the meantime i want to clear onething that the problem is not specifically related to the use of popup (or lookup). Even if i use combo box with showing the service type name on front and at the backend having its value as it primary key the problem also came. I went through my copy of "Hibernate in Action" and in chapter i found a paragraph mentioning hibernate working on this and it appears from there that hibernate checks the value of primary key for not null and also if it found version number than checks its as well so there the root of problem ( i am not saying that hibernate is doing anything wrong there u ppl are best at ORM and i know that it is a difficult topic and hats off to u r great work).Can u suggest any alternative here or how would u handle the situation with say combobox or lookup (specially the lookup as my main page dont fetch all the service types). One of the solution struck to my mind was to make an inetrceptor and then seeing that if primary key is set than the object is not transient. Is this a good thing to do and any alternatives u ppl can suggest.

For u r refernce these rae my objects and mappings (using annotations)

Code:
package com.inov8.iserv.common.model;

import java.util.*;
import javax.persistence.*;
import org.apache.commons.lang.builder.*;
import com.inov8.iserv.common.model.framework.*;


import com.inov8.iserv.common.model.*;
import javax.persistence.*;
import com.inov8.iserv.*;

/**
* The ServiceModel entity bean.
*
* @author  Shoaib Akhtar  Inov8 Limited
* @version $Revision: 1.20 $, $Date: 2006/03/06 19:29:08 $
*
*
* @spring.bean name="ServiceModel"
*/
@Entity
@org.hibernate.annotations.Entity(dynamicInsert = true)
@javax.persistence.SequenceGenerator(name = "SERVICE_seq",sequenceName = "SERVICE_seq", initialValue = 0)
@Table(name = "SERVICE")
public class ServiceModel extends BasePersistableModel {
 

   private ServiceTypeModel serviceTypeIdServiceTypeModel;


   private Long serviceId;
   private String name;
   private Boolean active;
   private String description;
   private String comments;
   private Date createdOn;
   private Date updatedOn;
   private Integer versionNo;

   /**
    * Default constructor.
    */
   public ServiceModel() {
   }

   /**
    * Value object constructor.
    */
   public ServiceModel(ServiceModel value) {   
      if (value != null) {         
         setServiceId(value.getServiceId());         
      }
      if (value != null) {         
         setServiceTypeId(value.getServiceTypeId());         
      }
      if (value != null) {         
         setName(value.getName());         
      }
      if (value != null) {         
         setActive(value.getActive());         
      }
      if (value != null) {         
         setDescription(value.getDescription());         
      }
      if (value != null) {         
         setComments(value.getComments());         
      }
      if (value != null) {         
         setCreatedBy(value.getCreatedBy());         
      }
      if (value != null) {         
         setUpdatedBy(value.getUpdatedBy());         
      }
      if (value != null) {         
         setCreatedOn(value.getCreatedOn());         
      }
      if (value != null) {         
         setUpdatedOn(value.getUpdatedOn());         
      }
      if (value != null) {         
         setVersionNo(value.getVersionNo());         
      }
   }

    /**
     * Return the primary key.
     *
     * @return Long with the primary key.
     */
   @javax.persistence.Transient
   public Long getPrimaryKey() {
        return getServiceId();
    }

    /**
     * Set the primary key.
     *
     * @param primaryKey the primary key
     */
   @javax.persistence.Transient
   public void setPrimaryKey(Long primaryKey) {
       setServiceId(primaryKey);
    }

   /**
    * Returns the value of the <code>serviceId</code> property.
    *
    */
      @Column(name = "SERVICE_ID" , nullable = false )
   @Id @GeneratedValue(strategy=GenerationType.SEQUENCE, generator="SERVICE_seq")
   public Long getServiceId() {
      return serviceId;
   }

   /**
    * Sets the value of the <code>serviceId</code> property.
    *
    * @param serviceId the value for the <code>serviceId</code> property
    *   
          */

   public void setServiceId(Long serviceId) {
      this.serviceId = serviceId;
   }

   /**
    * Returns the value of the <code>name</code> property.
    *
    */
      @Column(name = "NAME" , nullable = false , length=50 )
   public String getName() {
      return name;
   }

   /**
    * Sets the value of the <code>name</code> property.
    *
    * @param name the value for the <code>name</code> property
    *   
           * @spring.validator type="required"
    * @spring.validator type="maxlength"     
    * @spring.validator-args arg1value="${var:maxlength}"
    * @spring.validator-var name="maxlength" value="50"   
    */

   public void setName(String name) {
      this.name = name;
   }

   /**
    * Returns the value of the <code>active</code> property.
    *
    */
      @Column(name = "IS_ACTIVE" , nullable = false )
   public Boolean getActive() {
      return active;
   }

   /**
    * Sets the value of the <code>active</code> property.
    *
    * @param active the value for the <code>active</code> property
    *   
           * @spring.validator type="required"
      * @spring.validator type="boolean"
    */

   public void setActive(Boolean active) {
      this.active = active;
   }

   /**
    * Returns the value of the <code>description</code> property.
    *
    */
      @Column(name = "DESCRIPTION"  , length=255 )
   public String getDescription() {
      return description;
   }

   /**
    * Sets the value of the <code>description</code> property.
    *
    * @param description the value for the <code>description</code> property
    *   
          * @spring.validator type="maxlength"     
    * @spring.validator-args arg1value="${var:maxlength}"
    * @spring.validator-var name="maxlength" value="255"   
    */

   public void setDescription(String description) {
      this.description = description;
   }

   /**
    * Returns the value of the <code>comments</code> property.
    *
    */
      @Column(name = "COMMENTS"  , length=255 )
   public String getComments() {
      return comments;
   }

   /**
    * Sets the value of the <code>comments</code> property.
    *
    * @param comments the value for the <code>comments</code> property
    *   
          * @spring.validator type="maxlength"     
    * @spring.validator-args arg1value="${var:maxlength}"
    * @spring.validator-var name="maxlength" value="255"   
    */

   public void setComments(String comments) {
      this.comments = comments;
   }

   /**
    * Returns the value of the <code>createdOn</code> property.
    *
    */
      @Column(name = "CREATED_ON"  )
   public Date getCreatedOn() {
      return createdOn;
   }

   /**
    * Sets the value of the <code>createdOn</code> property.
    *
    * @param createdOn the value for the <code>createdOn</code> property
    *   
          */

   public void setCreatedOn(Date createdOn) {
      this.createdOn = createdOn;
   }

   /**
    * Returns the value of the <code>updatedOn</code> property.
    *
    */
      @Column(name = "UPDATED_ON"  )
   public Date getUpdatedOn() {
      return updatedOn;
   }

   /**
    * Sets the value of the <code>updatedOn</code> property.
    *
    * @param updatedOn the value for the <code>updatedOn</code> property
    *   
          */

   public void setUpdatedOn(Date updatedOn) {
      this.updatedOn = updatedOn;
   }

   /**
    * Returns the value of the <code>versionNo</code> property.
    *
    */
      @Version
       @Column(name = "VERSION_NO"  )
   public Integer getVersionNo() {
      return versionNo;
   }

   /**
    * Sets the value of the <code>versionNo</code> property.
    *
    * @param versionNo the value for the <code>versionNo</code> property
    *   
          */

   public void setVersionNo(Integer versionNo) {
      this.versionNo = versionNo;
   }

   /**
    * Returns the value of the <code>serviceTypeIdServiceTypeModel</code> relation property.
    *
    * @return the value of the <code>serviceTypeIdServiceTypeModel</code> relation property.
    *
    */
   @ManyToOne(cascade = CascadeType.REFRESH, fetch = FetchType.EAGER)
   @JoinColumn(name = "SERVICE_TYPE_ID")   
   public ServiceTypeModel getRelationServiceTypeIdServiceTypeModel(){
      return serviceTypeIdServiceTypeModel;
   }
   
   /**
    * Returns the value of the <code>serviceTypeIdServiceTypeModel</code> relation property.
    *
    * @return the value of the <code>serviceTypeIdServiceTypeModel</code> relation property.
    *
    */
   @javax.persistence.Transient
   public ServiceTypeModel getServiceTypeIdServiceTypeModel(){
      return getRelationServiceTypeIdServiceTypeModel();
   }

   /**
    * Sets the value of the <code>serviceTypeIdServiceTypeModel</code> relation property.
    *
    * @param serviceTypeModel a value for <code>serviceTypeIdServiceTypeModel</code>.
    */
   @javax.persistence.Transient
   public void setRelationServiceTypeIdServiceTypeModel(ServiceTypeModel serviceTypeModel) {
      this.serviceTypeIdServiceTypeModel = serviceTypeModel;
   }
   
   /**
    * Sets the value of the <code>serviceTypeIdServiceTypeModel</code> relation property.
    *
    * @param serviceTypeModel a value for <code>serviceTypeIdServiceTypeModel</code>.
    */
   @javax.persistence.Transient
   public void setServiceTypeIdServiceTypeModel(ServiceTypeModel serviceTypeModel) {
      setRelationServiceTypeIdServiceTypeModel(new ServiceTypeModel(serviceTypeModel));
   }
   



   /**
    * Returns the value of the <code>serviceTypeId</code> property.
    *
    */
   @javax.persistence.Transient
   public Long getServiceTypeId() {
      if (serviceTypeIdServiceTypeModel != null) {
         return serviceTypeIdServiceTypeModel.getServiceTypeId();
      } else {
         return null;
      }
   }

   /**
    * Sets the value of the <code>serviceTypeId</code> property.
    *
    * @param serviceTypeId the value for the <code>serviceTypeId</code> property
    */
   @javax.persistence.Transient
   public void setServiceTypeId(Long serviceTypeId) {
      if (serviceTypeIdServiceTypeModel == null) {
        serviceTypeIdServiceTypeModel = new ServiceTypeModel();
      }
      serviceTypeIdServiceTypeModel.setServiceTypeId(serviceTypeId);
   }


    /**
     * Used by the display tag library for rendering a checkbox in the list.
     * @return String with a HTML checkbox.
     */
    @Transient
    public String getCheckbox() {
        String checkBox = "<input type=\"checkbox\" name=\"checkbox";
        checkBox += "_"+ getServiceId();
        checkBox += "\"/>";
        return checkBox;
    }

   /**
    * Helper method for Struts with displaytag
    */
   @javax.persistence.Transient
   public String getPrimaryKeyParameters() {
      String parameters = "";
      parameters += "&serviceId=" + getServiceId();
      return parameters;
   }
   /**
     * Helper method for default Sorting on Primary Keys
     */
    @javax.persistence.Transient
    public String[] getPrimaryKeysFieldName()
    {
      ArrayList<String> pkFieldNameList = new ArrayList<String>();
         pkFieldNameList.add("serviceId");
         String[] pkFieldNameArray = new String[pkFieldNameList.size()];
         return (String[])pkFieldNameList.toArray(pkFieldNameArray);            
    }

}



and the other one is
Code:
package com.inov8.iserv.common.model;

import java.util.*;
import javax.persistence.*;
import org.apache.commons.lang.builder.*;
import com.inov8.iserv.common.model.framework.*;


import com.inov8.iserv.common.model.*;
import javax.persistence.*;
import com.inov8.iserv.*;

/**
* The ServiceTypeModel entity bean.
*
* @author  Shoaib Akhtar  Inov8 Limited
* @version $Revision: 1.20 $, $Date: 2006/03/06 19:29:08 $
*
*
* @spring.bean name="ServiceTypeModel"
*/
@Entity
@org.hibernate.annotations.Entity(dynamicInsert = true)
@javax.persistence.SequenceGenerator(name = "SERVICE_TYPE_seq",sequenceName = "SERVICE_TYPE_seq", initialValue = 0)
@Table(name = "SERVICE_TYPE")
public class ServiceTypeModel extends BasePersistableModel {
 


   private Collection<ServiceModel> serviceTypeIdServiceModelList = new ArrayList<ServiceModel>();

   private Long serviceTypeId;
   private String name;
   private Boolean active;
   private String description;
   private String comments;
   private Date updatedOn;
   private Date createdOn;
   private Integer versionNo;

   /**
    * Default constructor.
    */
   public ServiceTypeModel() {
   }

   /**
    * Value object constructor.
    */
   public ServiceTypeModel(ServiceTypeModel value) {   
      if (value != null) {         
         setServiceTypeId(value.getServiceTypeId());         
      }
      if (value != null) {         
         setName(value.getName());         
      }
      if (value != null) {         
         setActive(value.getActive());         
      }
      if (value != null) {         
         setDescription(value.getDescription());         
      }
      if (value != null) {         
         setComments(value.getComments());         
      }
      if (value != null) {         
         setCreatedBy(value.getCreatedBy());         
      }
      if (value != null) {         
         setUpdatedBy(value.getUpdatedBy());         
      }
      if (value != null) {         
         setUpdatedOn(value.getUpdatedOn());         
      }
      if (value != null) {         
         setCreatedOn(value.getCreatedOn());         
      }
      if (value != null) {         
         setVersionNo(value.getVersionNo());         
      }
   }

    /**
     * Return the primary key.
     *
     * @return Long with the primary key.
     */
   @javax.persistence.Transient
   public Long getPrimaryKey() {
        return getServiceTypeId();
    }

    /**
     * Set the primary key.
     *
     * @param primaryKey the primary key
     */
   @javax.persistence.Transient
   public void setPrimaryKey(Long primaryKey) {
       setServiceTypeId(primaryKey);
    }

   /**
    * Returns the value of the <code>serviceTypeId</code> property.
    *
    */
      @Column(name = "SERVICE_TYPE_ID" , nullable = false )
   @Id @GeneratedValue(strategy=GenerationType.SEQUENCE, generator="SERVICE_TYPE_seq")
   public Long getServiceTypeId() {
      return serviceTypeId;
   }

   /**
    * Sets the value of the <code>serviceTypeId</code> property.
    *
    * @param serviceTypeId the value for the <code>serviceTypeId</code> property
    *   
          */

   public void setServiceTypeId(Long serviceTypeId) {
      this.serviceTypeId = serviceTypeId;
   }

   /**
    * Returns the value of the <code>name</code> property.
    *
    */
      @Column(name = "NAME" , nullable = false , length=50 )
   public String getName() {
      return name;
   }

   /**
    * Sets the value of the <code>name</code> property.
    *
    * @param name the value for the <code>name</code> property
    *   
           * @spring.validator type="required"
    * @spring.validator type="maxlength"     
    * @spring.validator-args arg1value="${var:maxlength}"
    * @spring.validator-var name="maxlength" value="50"   
    */

   public void setName(String name) {
      this.name = name;
   }

   /**
    * Returns the value of the <code>active</code> property.
    *
    */
      @Column(name = "IS_ACTIVE" , nullable = false )
   public Boolean getActive() {
      return active;
   }

   /**
    * Sets the value of the <code>active</code> property.
    *
    * @param active the value for the <code>active</code> property
    *   
           * @spring.validator type="required"
      * @spring.validator type="boolean"
    */

   public void setActive(Boolean active) {
      this.active = active;
   }

   /**
    * Returns the value of the <code>description</code> property.
    *
    */
      @Column(name = "DESCRIPTION"  , length=255 )
   public String getDescription() {
      return description;
   }

   /**
    * Sets the value of the <code>description</code> property.
    *
    * @param description the value for the <code>description</code> property
    *   
          * @spring.validator type="maxlength"     
    * @spring.validator-args arg1value="${var:maxlength}"
    * @spring.validator-var name="maxlength" value="255"   
    */

   public void setDescription(String description) {
      this.description = description;
   }

   /**
    * Returns the value of the <code>comments</code> property.
    *
    */
      @Column(name = "COMMENTS"  , length=255 )
   public String getComments() {
      return comments;
   }

   /**
    * Sets the value of the <code>comments</code> property.
    *
    * @param comments the value for the <code>comments</code> property
    *   
          * @spring.validator type="maxlength"     
    * @spring.validator-args arg1value="${var:maxlength}"
    * @spring.validator-var name="maxlength" value="255"   
    */

   public void setComments(String comments) {
      this.comments = comments;
   }

   /**
    * Returns the value of the <code>updatedOn</code> property.
    *
    */
      @Column(name = "UPDATED_ON"  )
   public Date getUpdatedOn() {
      return updatedOn;
   }

   /**
    * Sets the value of the <code>updatedOn</code> property.
    *
    * @param updatedOn the value for the <code>updatedOn</code> property
    *   
          */

   public void setUpdatedOn(Date updatedOn) {
      this.updatedOn = updatedOn;
   }

   /**
    * Returns the value of the <code>createdOn</code> property.
    *
    */
      @Column(name = "CREATED_ON"  )
   public Date getCreatedOn() {
      return createdOn;
   }

   /**
    * Sets the value of the <code>createdOn</code> property.
    *
    * @param createdOn the value for the <code>createdOn</code> property
    *   
          */

   public void setCreatedOn(Date createdOn) {
      this.createdOn = createdOn;
   }

   /**
    * Returns the value of the <code>versionNo</code> property.
    *
    */
      @Version
       @Column(name = "VERSION_NO"  )
   public Integer getVersionNo() {
      return versionNo;
   }

   /**
    * Sets the value of the <code>versionNo</code> property.
    *
    * @param versionNo the value for the <code>versionNo</code> property
    *   
          */

   public void setVersionNo(Integer versionNo) {
      this.versionNo = versionNo;
   }


   /**
    * Add the related ServiceModel to this one-to-many relation.
    *
    * @param serviceModel object to be added.
    */
   
   public void addServiceTypeIdServiceModel(ServiceModel serviceModel) {
      serviceModel.setRelationServiceTypeIdServiceTypeModel(this);
      serviceTypeIdServiceModelList.add(serviceModel);
   }

   /**
    * Get a list of related ServiceModel objects of the ServiceTypeModel object.
    * These objects are in a bidirectional one-to-many relation by the ServiceTypeId member.
    *
    * @return Collection of ServiceModel objects.
    *
    */
   @OneToMany(cascade={CascadeType.PERSIST,CascadeType.MERGE,CascadeType.REFRESH}, fetch = FetchType.LAZY, mappedBy = "relationServiceTypeIdServiceTypeModel")
   @JoinColumn(name = "SERVICE_TYPE_ID")   
   @org.hibernate.annotations.Cascade(
                                       {org.hibernate.annotations.CascadeType.
                                       SAVE_UPDATE,
                                       org.hibernate.annotations.CascadeType.
                                       PERSIST,
                                       org.hibernate.annotations.CascadeType.
                                       MERGE,
                                       org.hibernate.annotations.CascadeType.
                                       REFRESH})
   public Collection<ServiceModel> getServiceTypeIdServiceModelList() throws Exception {
         return serviceTypeIdServiceModelList;
   }


   /**
    * Set a list of ServiceModel related objects to the ServiceTypeModel object.
    * These objects are in a bidirectional one-to-many relation by the ServiceTypeId member.
    *
    * @param serviceModelList the list of related objects.
    */
    public void setServiceTypeIdServiceModelList(Collection<ServiceModel> serviceModelList) throws Exception {
      this.serviceTypeIdServiceModelList = serviceModelList;
   }




    /**
     * Used by the display tag library for rendering a checkbox in the list.
     * @return String with a HTML checkbox.
     */
    @Transient
    public String getCheckbox() {
        String checkBox = "<input type=\"checkbox\" name=\"checkbox";
        checkBox += "_"+ getServiceTypeId();
        checkBox += "\"/>";
        return checkBox;
    }

   /**
    * Helper method for Struts with displaytag
    */
   @javax.persistence.Transient
   public String getPrimaryKeyParameters() {
      String parameters = "";
      parameters += "&serviceTypeId=" + getServiceTypeId();
      return parameters;
   }
   /**
     * Helper method for default Sorting on Primary Keys
     */
    @javax.persistence.Transient
    public String[] getPrimaryKeysFieldName()
    {
      ArrayList<String> pkFieldNameList = new ArrayList<String>();
         pkFieldNameList.add("serviceTypeId");
         String[] pkFieldNameArray = new String[pkFieldNameList.size()];
         return (String[])pkFieldNameList.toArray(pkFieldNameArray);            
    }

}



Please reply me soon as i am dire need of u r help. Also suggest me if i need to use Collection or Set form ampping one to many side?.Thanks in advance.

Regards,
Shoaib Akhtar


Top
 Profile  
 
 Post subject:
PostPosted: Wed Apr 12, 2006 1:46 am 
Regular
Regular

Joined: Tue Mar 23, 2004 2:10 am
Posts: 51
Hi,
Still waiting for any kind of reply. To keep things simple and understandable take this scenerio that suppose if in CaveatEmptor application (from Hibernate in Action) the relationship between Categories and Items is One to Many so that item can belong to only one category at a time and other thing is that Category table has a version number field. Now if we have a form to create a new item and on this form we have to select a category to which this item belongs and to choose it we have a combo box showing all the categories (with combo box showing category name and its value is category primary key). Now how would we handle this situation (lets say that we are using Struts as web app framework).

Now if i have a binding of category primary key i.e. category_id with the category_id of item object and in the setter implementation i have follwoing method in item class setCategoryId(Long id) and it does new Category(); and then setCategoryId(id); and category.getItems().addItem(this); and finally this.categoruy= category; it gives me exception and the reason i found is that the version number property is null and lead hibernate to beleive or say guess that this Category is transient even though its primary key is set. Please suggest any good solution.

Please reply me asap.

Regards,
Shoaib Akhtar


Top
 Profile  
 
 Post subject:
PostPosted: Fri Apr 14, 2006 10:13 am 
Regular
Regular

Joined: Tue Mar 23, 2004 2:10 am
Posts: 51
Hi,
Does anybody interested in replying and earning one credit?


Top
 Profile  
 
 Post subject: Having same problem
PostPosted: Fri Apr 14, 2006 3:35 pm 
Newbie

Joined: Mon Mar 21, 2005 6:55 pm
Posts: 2
I'm having the same problem you described in your post (and described here http://forum.hibernate.org/viewtopic.php?p=2300911).

Did you ever find a better solution than using <version>?

Thanks,
Jed


Top
 Profile  
 
 Post subject:
PostPosted: Sat Apr 15, 2006 7:25 am 
Regular
Regular

Joined: Tue Mar 23, 2004 2:10 am
Posts: 51
Hi,
Thanks for u r reply, o tried same solution of setting version number to meaningless value and it also worked for me but i really did not liked the approach at all.

The second workaround that i am actually using right now is to make an interceptor that is extending EmptyInterceptor calls and overriding the isTransint method and see that if the object given is BasePersistableModel (My own class and all my Persistant classes extends this) and its primary key is not null (getPrimaryKey exists in BasePersistableModel as abstract method and subclasses impelment this ) then i return false form it. As all my primary keys are getting there values from Oracle Sequence and there is no user assigned values it is working perfectly good in almost all cases except one.

But i posted the problem here just to know what could be the best way of doing this. It must be a common issue and i expected to get quick reply from the community but its strange to find that nobody is very much intereseted. Do all of the people use hibernate in ideal ircumstances ?

in BTW plz do reply and fiind a better way if there is any.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 6 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.