-->
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: Moved to a new server, and experiencing issues
PostPosted: Thu Jan 08, 2009 2:08 am 
Newbie

Joined: Thu Jan 08, 2009 1:40 am
Posts: 1
For the last few years we've had much success with our spring/hibernate application. Thank you to the creators of hibernate for this awesome project.

We recently moved to a new server, and 95% of the application works great. It's an news article publishing system. Users can add new articles and assign pictures to them.

The problem is, when attempting to add an image to an article, the infamous "No row with the given identifier exists" error is thrown. I tried searching for answers to this common problem, but I keep coming back to this: It worked fine on the old server, so why does it not work on the new server? It must be some environment difference.

Would a difference in versions for Java or MySQL cause this problem?

Hibernate version:
3

Mapping documents:
Here is the mapping for the Publication object:
Code:
<?xml version="1.0"?>

<!DOCTYPE hibernate-mapping PUBLIC
    "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
    "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">

<hibernate-mapping>

  <class name="stpns.dom.Publication" table="publications" dynamic-update="false" dynamic-insert="false" lazy="true" batch-size="10">

    <id name="id" column="publication_id" type="int" unsaved-value="0">
      <generator class="native"></generator>
    </id>

    <component name="contactDetails" class="stpns.dom.ContactDetails" insert="true" update="true">
      <property name="phoneNumber" type="string" column="phone" not-null="true" unique="false" />
      <property name="faxNumber" type="string" column="fax" not-null="true" unique="false" />
      <property name="email" type="string" column="email" not-null="true" unique="false" />
      <property name="streetName" type="string" column="street" not-null="true" unique="false" />
      <property name="streetName2" type="string" column="street2" not-null="false" unique="false" />
      <property name="zipCode" type="string" column="zip" not-null="true" unique="false" />
     
      <many-to-one name="city" column="city_id" class="stpns.dom.City" cascade="save-update" fetch="join" outer-join="auto" update="true" insert="true" />
      <many-to-one name="state" column="state_id" class="stpns.dom.State" cascade="save-update" fetch="join" outer-join="auto" update="true" insert="true" />
      <many-to-one name="country" column="country_id" class="stpns.dom.Country" cascade="save-update" fetch="join" outer-join="auto" update="true" insert="true" />
    </component>

    <many-to-one name="publisher" class="stpns.dom.Publisher" column="publisher_id" fetch="join" />

    <property name="name" type="string" update="true" insert="true" column="name" not-null="true" unique="false" />
   
    <property name="website" type="string" update="true" insert="true" column="website" not-null="false" unique="false" />
    <property name="pubcode" type="string" update="true" insert="true" column="pubcode" not-null="false" unique="false" />

    <property name="objectState" type="int" update="true" insert="true" column="object_state" not-null="true" unique="false" />
   
    <set name="mediaObjects" table="publications_media_objects" fetch="join" lazy="true" cascade="all" batch-size="5">
      <key column="publication_id"/>
      <many-to-many class="stpns.dom.MediaObject" column="object_id"  fetch="join"/>
    </set>
  </class>

</hibernate-mapping>


Here is the mapping for the MediaObject :
Code:
<?xml version="1.0"?>

<!DOCTYPE hibernate-mapping PUBLIC
    "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
    "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">

<hibernate-mapping>

  <class name="stpns.dom.MediaObject" table="media_objects"
    dynamic-update="false" dynamic-insert="false" lazy="true" batch-size="10">

    <id name="id" column="object_id" type="integer" unsaved-value="0">
      <generator class="native"></generator>
    </id>

    <property name="name" type="string" update="true" insert="true"
      column="name" not-null="true" unique="false" />

    <property name="originalName" type="string" update="true" insert="true"
      column="original_name" not-null="true" unique="false" />

    <property name="description" type="string" update="true" insert="true"
      column="description" not-null="true" unique="false" />

    <property name="author" type="string" update="true" insert="true"
      column="author" not-null="true" unique="false" />

    <property name="mimeType" type="string" update="true" insert="true"
      column="mime_type" not-null="true" unique="false" />

    <property name="filename" type="string" update="true" insert="true"
      column="filename" not-null="true" unique="false" />

    <property name="uploadDate" type="timestamp" update="true" insert="true"
      column="upload_date" not-null="true" unique="false" />

    <property name="objectState" type="int" update="true" insert="true"
      column="object_state" not-null="true" unique="false" />

    <property name="fileSize" type="int" update="true" insert="true"
      column="filesize" not-null="true" unique="false" />

    <property name="horizontelPixels" type="int" update="true" insert="true"
      column="h_pixels" not-null="true" unique="false" />

    <property name="verticalPixels" type="int" update="true" insert="true"
      column="v_pixels" not-null="true" unique="false" />

    <property name="horizontelDpi" type="double" update="true" insert="true"
      column="h_dpi" not-null="true" unique="false" />

    <property name="verticalDpi" type="double" update="true" insert="true"
      column="v_dpi" not-null="true" unique="false" />

  </class>

</hibernate-mapping>



Here is the line of code where it all starts:
Code:
publication.addMediaObject(photo);


Here is the Publication object:
Code:
package stpns.dom;

import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

import stpns.util.AccountUtility;
import stpns.util.DesEncrypter;

/**
* @author ovi, 2005.
*/
public class Publication {
   private int id;
   private String name;
   private String website;
   private ContactDetails contactDetails;
   private Publisher publisher;
   private List articles;
   private Set mediaObjects;
   private int objectState;
   private String pubcode; 

   public Publication() {
   }

   public Publication(int id, String name) {
      setId(id);
      setName(name);
   }

   public ContactDetails getContactDetails() {
      return contactDetails;
   }

   public void setContactDetails(ContactDetails contactDetails) {
      this.contactDetails = contactDetails;
   }

   public int getId() {
      return id;
   }

   public void setId(int id) {
      this.id = id;
   }

   public String getIdEncoded() {
      DesEncrypter encrypter = new DesEncrypter();
      
      String ret = null;
      try {
         ret = URLEncoder.encode(encrypter.encrypt("" + id), "UTF-8");
      } catch (UnsupportedEncodingException e) {
         e.printStackTrace();
      }
      return ret;
   }

   public int getIdDecoded(String id) {
      DesEncrypter encrypter = new DesEncrypter();
      return Integer.parseInt(encrypter.decrypt(id));
   }

   public String getName() {
      return name;
   }

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

   public Publisher getPublisher() {
      return publisher;
   }

   public void setPublisher(Publisher publisher) {
      this.publisher = publisher;
   }

   public int getObjectState() {
      return objectState;
   }

   public void setObjectState(int objectState) {
      this.objectState = objectState;
   }

   public List getArticles() {
      return articles;
   }

   public void setArticles(List articles) {
      this.articles = articles;
   }

   /**
    * Returns the value of mediaObjects.
    *
    * @return Returns the mediaObjects.
    */
   public Set getMediaObjects() {
      return this.mediaObjects;
   }

   /**
    * Set the mediaObjects value.
    *
    * @param mediaObjects
    *          The mediaObjects to set.
    */
   public void setMediaObjects(Set mediaObjects) {
      this.mediaObjects = mediaObjects;
   }

   public void addMediaObject(MediaObject mediaObject) {
      checkIntegrity();
      mediaObjects.add(mediaObject);
   }

   protected void checkIntegrity() {
      if(mediaObjects == null) {
         mediaObjects = new HashSet();
      }
   }

   public boolean equals(Object obj) {
      if(this == obj) {
         return true;
      }
      if((obj == null) || !(obj instanceof Publication)) {
         return false;
      }
      Publication publication = (Publication) obj;
      return (name == publication.getName() || (name != null && name.equals(publication.getName()))) && objectState == publication.getObjectState();
   }

   public int hashCode() {
      int hash = 1;
      hash = 31 * hash + ((name == null) ? "".hashCode() : name.hashCode());
      hash = 31 * hash + objectState;
      return hash;
   }

   public String getWebsite() {
      return this.website;
   }

   public void setWebsite(String website) {
      this.website = AccountUtility.getAppropriateUrl(website);
   }

   /**
    * @return Returns the pubcode.
    */
   public String getPubcode() {
      return pubcode;
   }

   /**
    * @param pubcode The pubcode to set.
    */
   public void setPubcode(String pubcode) {
      this.pubcode = pubcode;
   }
}


Here is the code for the MediaObject:
Code:
package stpns.dom;

import java.sql.Timestamp;

/**
* @author ovi, 2005
*/
public class MediaObject {
   private int id;
   private String name;
   private String originalName;
   private String description;
   private String author;
   private String mimeType;
   private String filename;
   private Timestamp uploadDate;
   private int fileSize;
   private int horizontelPixels;
   private int verticalPixels;
   private double horizontelDpi;
   private double verticalDpi;
   
   
   private int objectState;

   public MediaObject() {
   }

   /**
    * Returns the value of author.
    *
    * @return Returns the author.
    */
   public String getAuthor() {
      return this.author;
   }

   /**
    * Set the author value.
    *
    * @param author
    *          The author to set.
    */
   public void setAuthor(String author) {
      this.author = author;
   }

   /**
    * Returns the value of description.
    *
    * @return Returns the description.
    */
   public String getDescription() {
      return this.description;
   }

   /**
    * Set the description value.
    *
    * @param description
    *          The description to set.
    */
   public void setDescription(String description) {
      this.description = description;
   }

   /**
    * Returns the value of filename.
    *
    * @return Returns the filename.
    */
   public String getFilename() {
      return this.filename;
   }

   /**
    * Set the filename value.
    *
    * @param filename
    *          The filename to set.
    */
   public void setFilename(String filename) {
      this.filename = filename;
   }

   /**
    * Returns the value of id.
    *
    * @return Returns the id.
    */
   public int getId() {
      return this.id;
   }

   /**
    * Set the id value.
    *
    * @param id
    *          The id to set.
    */
   public void setId(int id) {
      this.id = id;
   }

   /**
    * Returns the value of mimeType.
    *
    * @return Returns the mimeType.
    */
   public String getMimeType() {
      return this.mimeType;
   }

   /**
    * Set the mimeType value.
    *
    * @param mimeType
    *          The mimeType to set.
    */
   public void setMimeType(String mimeType) {
      this.mimeType = mimeType;
   }

   /**
    * Returns the value of name.
    *
    * @return Returns the name.
    */
   public String getName() {
      return this.name;
   }

   /**
    * Set the name value.
    *
    * @param name
    *          The name to set.
    */
   public void setName(String name) {
      this.name = name;
   }

   /**
    * Returns the value of objectState.
    *
    * @return Returns the objectState.
    */
   public int getObjectState() {
      return this.objectState;
   }

   /**
    * Set the objectState value.
    *
    * @param objectState
    *          The objectState to set.
    */
   public void setObjectState(int objectState) {
      this.objectState = objectState;
   }

   /**
    * Returns the value of uploadDate.
    *
    * @return Returns the uploadDate.
    */
   public Timestamp getUploadDate() {
      return this.uploadDate;
   }

   /**
    * Set the uploadDate value.
    *
    * @param uploadDate
    *          The uploadDate to set.
    */
   public void setUploadDate(Timestamp uploadDate) {
      this.uploadDate = uploadDate;
   }
   
   public boolean equals(Object obj) {
      if(this == obj) {
         return true;
      }
      if((obj == null) || !(obj instanceof Category)) {
         return false;
      }
      MediaObject mediaObject = (MediaObject) obj;
      return objectState == mediaObject.getObjectState() && (name == mediaObject.getName() || (name != null && name.equals(mediaObject.getName()))) && (filename == mediaObject.getFilename() || (filename != null && filename.equals(mediaObject.getFilename())));
   }

   public int hashCode() {
      int hash = 1;
      hash = 31 * hash + ((name == null) ? "".hashCode() : name.hashCode());
      hash = 31 * hash + ((filename == null) ? "".hashCode() : filename.hashCode());
      hash = 31 * hash + objectState;
      return hash;
   }

   /**
    * Returns the value of originalName.
    * @return Returns the originalName.
    */
   public String getOriginalName() {
      return this.originalName;
   }

   /**
    * Set the originalName value.
    * @param originalName The originalName to set.
    */
   public void setOriginalName(String originalName) {
      this.originalName = originalName;
   }

   /**
    * @return Returns the fileSize.
    */
   public int getFileSize() {
      return fileSize;
   }

   /**
    * @param fileSize The fileSize to set.
    */
   public void setFileSize(int fileSize) {
      this.fileSize = fileSize;
   }

   /**
    * @return Returns the horizontelDpi.
    */
   public double getHorizontelDpi() {
      return horizontelDpi;
   }

   /**
    * @param horizontelDpi The horizontelDpi to set.
    */
   public void setHorizontelDpi(double horizontelDpi) {
      this.horizontelDpi = horizontelDpi;
   }

   /**
    * @return Returns the horizontelPixels.
    */
   public int getHorizontelPixels() {
      return horizontelPixels;
   }

   /**
    * @param horizontelPixels The horizontelPixels to set.
    */
   public void setHorizontelPixels(int horizontelPixels) {
      this.horizontelPixels = horizontelPixels;
   }

   /**
    * @return Returns the vertialPixels.
    */
   public int getVerticalPixels() {
      return verticalPixels;
   }

   /**
    * @param vertialPixels The vertialPixels to set.
    */
   public void setVerticalPixels(int verticalPixels) {
      this.verticalPixels = verticalPixels;
   }

   /**
    * @return Returns the verticalDpi.
    */
   public double getVerticalDpi() {
      return verticalDpi;
   }

   /**
    * @param verticalDpi The verticalDpi to set.
    */
   public void setVerticalDpi(double verticalDpi) {
      this.verticalDpi = verticalDpi;
   }

}


Full stack trace of any exception that occurs:
org.springframework.web.util.NestedServletException: Request processing failed; nested exception is org.hibernate.ObjectNotFoundException: No row with the given identifier exists: [stpns.dom.MediaObject#27]
org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:408)
org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:360)
javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)

root cause

org.hibernate.ObjectNotFoundException: No row with the given identifier exists: [stpns.dom.MediaObject#27]
org.hibernate.impl.SessionFactoryImpl$1.handleEntityNotFound(SessionFactoryImpl.java:377)
org.hibernate.proxy.AbstractLazyInitializer.checkTargetState(AbstractLazyInitializer.java:79)
org.hibernate.proxy.AbstractLazyInitializer.initialize(AbstractLazyInitializer.java:68)
org.hibernate.proxy.AbstractLazyInitializer.getImplementation(AbstractLazyInitializer.java:111)
org.hibernate.proxy.pojo.cglib.CGLIBLazyInitializer.invoke(CGLIBLazyInitializer.java:140)
stpns.dom.MediaObject$$EnhancerByCGLIB$$b25a0da9.hashCode(<generated>)
java.util.HashMap.put(HashMap.java:418)
java.util.HashSet.add(HashSet.java:194)
java.util.AbstractCollection.addAll(AbstractCollection.java:318)
org.hibernate.collection.PersistentSet.endRead(PersistentSet.java:329)
org.hibernate.engine.CollectionLoadContext.endLoadingCollection(CollectionLoadContext.java:183)
org.hibernate.engine.CollectionLoadContext.endLoadingCollections(CollectionLoadContext.java:268)
org.hibernate.engine.CollectionLoadContext.endLoadingCollections(CollectionLoadContext.java:249)
org.hibernate.loader.Loader.endCollectionLoad(Loader.java:866)
org.hibernate.loader.Loader.initializeEntitiesAndCollections(Loader.java:853)
org.hibernate.loader.Loader.doQuery(Loader.java:717)
org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:224)
org.hibernate.loader.Loader.loadCollection(Loader.java:1985)
org.hibernate.loader.collection.BatchingCollectionInitializer.initialize(BatchingCollectionInitializer.java:52)
org.hibernate.persister.collection.AbstractCollectionPersister.initialize(AbstractCollectionPersister.java:565)
org.hibernate.event.def.DefaultInitializeCollectionEventListener.onInitializeCollection(DefaultInitializeCollectionEventListener.java:60)
org.hibernate.impl.SessionImpl.initializeCollection(SessionImpl.java:1716)
org.hibernate.collection.AbstractPersistentCollection.initialize(AbstractPersistentCollection.java:344)
org.hibernate.collection.PersistentSet.add(PersistentSet.java:189)
stpns.dom.Publication.addMediaObject(Publication.java:120)
stpns.controller.articles.CreateArticleWizardController.handleArticlePhoto(CreateArticleWizardController.java:857)
stpns.controller.articles.CreateArticleWizardController.postProcessPage(CreateArticleWizardController.java:392)
org.springframework.web.servlet.mvc.AbstractWizardFormController.processFormSubmission(AbstractWizardFormController.java:503)
org.springframework.web.servlet.mvc.AbstractFormController.handleRequestInternal(AbstractFormController.java:250)
org.springframework.web.servlet.mvc.AbstractController.handleRequest(AbstractController.java:153)
org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter.handle(SimpleControllerHandlerAdapter.java:45)
org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:820)
org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:755)
org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:396)
org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:360)
javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)


Name and version of the database you are using:
MySQL
4.1.22-standard

Java
1.5.0_15

The generated SQL (show_sql=true):
Where do I put this?

Debug level Hibernate log excerpt:
Where do I put this?


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.