-->
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.  [ 4 posts ] 
Author Message
 Post subject: probleme methode save
PostPosted: Thu Feb 05, 2009 9:08 pm 
Regular
Regular

Joined: Wed Jan 28, 2009 8:31 pm
Posts: 54
Hi I have a problem with my code
Code:
public void update(ca.canassistance.pojo.BaseAvinfoge avinfoge)
         throws net.sf.hibernate.HibernateException, Exception{
      Session session = null;

      Transaction tx = null;
      try {
         session = HibernateUtil.currentSession();
         tx = session.beginTransaction();
         session.saveOrUpdate(avinfoge);
      
         [B][U]tx.commit();[/U][/B]

         HibernateUtil.closeSession();

      } catch (HibernateException e) {
         if (tx != null)
            tx.rollback();

         HibernateUtil.closeSession();
         e.printStackTrace();}
         catch (Exception e)
         {
            e.printStackTrace();      
         
         }
      
   }

and the error

19:55:42,192 DEBUG EntityPersister:627 - Updating entity: [ca.canassistance.pojo.BaseAvinfoge#ca.canassistance.pojo.AvinfogeId@be38819b]
19:55:42,192 DEBUG BatcherImpl:204 - about to open: 0 open PreparedStatements, 0 open ResultSets
19:55:42,192 DEBUG SQL:230 - update AVINFOGE set IG_ID_DOUBLE_ASS=?, IG_GROUPE_CLIENT=?, IG_NO_CERTIFICAT_SAM=?, IG_ID_USER=?, IG_DT_MODIF=?, IG_ID_ACCIDENT=? where IG_NO_GROUPE=? and IG_NO_CERTIFICAT=? and IG_DT_EVENEMENT=? and IG_NO_DOSSIER=?
19:55:42,192 DEBUG BatcherImpl:253 - preparing statement
19:55:42,192 DEBUG EntityPersister:382 - Dehydrating entity: [ca.canassistance.pojo.BaseAvinfoge#ca.canassistance.pojo.AvinfogeId@be38819b]
19:55:42,192 DEBUG StringType:46 - binding 'N' to parameter: 1
19:55:42,192 DEBUG StringType:46 - binding ' ' to parameter: 2
19:55:42,192 DEBUG StringType:46 - binding '18499190 ' to parameter: 3
19:55:42,192 DEBUG StringType:46 - binding 'STAR' to parameter: 4
19:55:42,192 DEBUG IntegerType:46 - binding '20090205' to parameter: 5
19:55:42,192 DEBUG StringType:46 - binding 'N' to parameter: 6
19:55:42,192 DEBUG StringType:46 - binding '052340' to parameter: 7
19:55:42,192 DEBUG StringType:46 - binding '18499190 ' to parameter: 8
19:55:42,192 DEBUG IntegerType:46 - binding '20090103' to parameter: 9
19:55:42,192 DEBUG StringType:46 - binding '422940' to parameter: 10
19:55:42,192 DEBUG BatcherImpl:28 - Adding to batch
19:55:42,192 DEBUG BatcherImpl:50 - Executing batch size: 1


after the executer of
Code:
tx.commit

my program get out and nothig append
no save or update. And it nerver go to the next
instruction.
I put some Exception for catching.
Nothig append to.
Code:
HibernateUtil.closeSession();


Can SomeOne help me please


Top
 Profile  
 
 Post subject:
PostPosted: Fri Feb 06, 2009 4:50 am 
Regular
Regular

Joined: Thu Sep 06, 2007 2:22 am
Posts: 108
Location: Noida,India
Could you please post Hibernate Configuration file (.cfg) and Hibernate Mapping file (.hbm) for Entity.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Feb 06, 2009 10:31 am 
Regular
Regular

Joined: Wed Jan 28, 2009 8:31 pm
Posts: 54
ok no problem
my hibernate.cfg.xml
Code:
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE hibernate-configuration
    PUBLIC "-//Hibernate/Hibernate Configuration DTD//EN"
    "http://hibernate.sourceforge.net/hibernate-configuration-2.0.dtd">

<hibernate-configuration>
    <session-factory name="factcan" >

      <!-- local connection properties -->
      <property name="hibernate.connection.url">jdbc:oracle:thin:@s1ora01s:1521:s1ora01i</property>
      <property name="hibernate.connection.driver_class">oracle.jdbc.OracleDriver</property>
      <property name="hibernate.connection.username">factcan</property>
      <property name="hibernate.connection.password">factcan</property>
      <!-- property name="hibernate.connection.pool_size"></property -->

      <!-- dialect for Oracle (any version) -->
        <property name="dialect">net.sf.hibernate.dialect.OracleDialect</property>

        <property name="hibernate.show_sql">false</property>
        <property name="hibernate.use_outer_join">true</property>
     <!--
        <property name="hibernate.transaction.factory_class">net.sf.hibernate.transaction.JTATransactionFactory</property>
        <property name="jta.UserTransaction">java:comp/UserTransaction</property>
-->
<property name="hibernate.transaction.factory_class">net.sf.hibernate.transaction.JDBCTransactionFactory</property>


<mapping resource="Avinfoge.hbm.xml"/>
    </session-factory>
   
     
</hibernate-configuration>


my hbm.xml
Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
   "-//Hibernate/Hibernate Mapping DTD//EN"
   "http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd" >

<hibernate-mapping package="ca.canassistance.pojo">
   <class
      name="BaseAvinfoge"
      table="AVINFOGE"
   >
   
   
   
   
    <composite-id name="id" class="ca.canassistance.pojo.AvinfogeId">

        <key-property name="noGroupe" column="IG_NO_GROUPE" type="string" length="6"/>
        <key-property name="noCertificat" column="IG_NO_CERTIFICAT" type="string"  length="10"/>
        <key-property name="dtEvenement" column="IG_DT_EVENEMENT" type="integer" length="8"/>
        <key-property name="noDossier" column="IG_NO_DOSSIER" type="string" length="6"/>
      </composite-id>
     
      <property
         name="doubleAss"
         column="IG_ID_DOUBLE_ASS"
         type="string"
         not-null="false"
         length="1"
      />
      
      <property
         name="groupeClient"
         column="IG_GROUPE_CLIENT"
         type="string"
         not-null="false"
         length="8"
      />
      <property
         name="noCertificatSam"
         column="IG_NO_CERTIFICAT_SAM"
         type="string"
         not-null="false"
         length="20"
      />
      
      
      <property
         name="idUser"
         column="IG_ID_USER"
         type="string"
         not-null="false"
         length="4"
      />
      <property
         name="dtModif"
         column="IG_DT_MODIF"
         type="integer"
         not-null="false"
         length="8"
      />
      <property
         name="idAccident"
         column="IG_ID_ACCIDENT"
         type="string"
         not-null="false"
         length="1"
      />


</class>
</hibernate-mapping>

and for finish
my class BaseAvinfoge
Code:
package pojo;

import java.io.Serializable;
import java.util.List;

import net.sf.hibernate.HibernateException;
import ca.canassistance.model.Avinfoge;
import ca.canassistance.model.dao.AvinfogeDAO;

/**
* This class has been automatically generated by Hibernate Synchronizer. For
* more information or documentation, visit The Hibernate Synchronizer page at
* http://www.binamics.com/hibernatesync or contact Joe Hudson at
* joe@binamics.com.
*
* This is an object that contains data related to the AVINFOGE table. Do not
* modify this class because it will be overwritten if the configuration file
* related to this class is modified.
*
* @hibernate.class table="AVINFOGE"
*/
public class BaseAvinfoge implements Serializable {

   /**
    *
    */
   private static final long serialVersionUID = -2444185467393453780L;

   // fields
   private java.lang.String doubleAss;

   //private java.lang.Integer dtEvenement;

   private java.lang.String groupeClient;

   //private java.lang.String noDossier;

   private java.lang.String noCertificatSam;

//   private java.lang.String noCertificat;

//   private java.lang.String noGroupe;

   private java.lang.String idUser;

   private java.lang.Integer dtModif;

   private java.lang.String idAccident;

   private AvinfogeId id;

   private AvinfogeDAO dao;

   // constructors
   public BaseAvinfoge(String doubleAss, Integer dtEvenement,
         String groupeClient, String noDossier, String noCertificatSam,
         String noCertificat, String noGroupe, String idUser,
         Integer dtModif, String idAccident)
   {
      AvinfogeId avinfogeId = new AvinfogeId();
      avinfogeId.setDtEvenement(dtEvenement);
      avinfogeId.setNoCertificat(noCertificat);
      avinfogeId.setNoDossier(noDossier);
      avinfogeId.setNoGroupe(noGroupe);
      this.setDoubleAss(doubleAss);

      this.setGroupeClient(groupeClient);
   
      this.setNoCertificatSam(noCertificatSam);
   
   
      this.setIdUser(idUser);
      this.setDtModif(dtModif);
      this.setIdAccident(idAccident);
      this.setId(avinfogeId);
      
   }

   public BaseAvinfoge() {
      initialize();
   }

   

   public BaseAvinfoge(Avinfoge avinfoge) {
      AvinfogeId id = new AvinfogeId();
      id.setDtEvenement(avinfoge.getDtEvenement());
      id.setNoCertificat(avinfoge.getNoCertificat());
      id.setNoDossier(avinfoge.getNoDossier());
      id.setNoGroupe(avinfoge.getNoGroupe());
      this.setId(id);
      this.setDoubleAss(avinfoge.getIdDoubleAss());
      //this.setDtModif(avinfoge.getModif);
      this.setGroupeClient(avinfoge.getGroupeClient());
      this.setIdAccident(avinfoge.getIdAccident());
      this.setNoCertificatSam(avinfoge.getNoCertificatSam());
      //avinfoge.getn
      
      
   }

   protected void initialize() {
   }

   public static long getSerialVersionUID() {
      return serialVersionUID;
   }

   public java.lang.String getDoubleAss() {
      return doubleAss;
   }

   public void setDoubleAss(java.lang.String doubleAss) {
      this.doubleAss = doubleAss;
   }

   

   public java.lang.Integer getDtModif() {
      return dtModif;
   }

   public void setDtModif(java.lang.Integer dtModif) {
      this.dtModif = dtModif;
   }

   public java.lang.String getGroupeClient() {
      return groupeClient;
   }

   public void setGroupeClient(java.lang.String groupeClient) {
      this.groupeClient = groupeClient;
   }

   public AvinfogeId getId() {
      return id;
   }

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

   public java.lang.String getIdAccident() {
      return idAccident;
   }

   public void setIdAccident(java.lang.String idAccident) {
      this.idAccident = idAccident;
   }

   public java.lang.String getIdUser() {
      return idUser;
   }

   public void setIdUser(java.lang.String idUser) {
      this.idUser = idUser;
   }

   

   public java.lang.String getNoCertificatSam() {
      return noCertificatSam;
   }

   public void setNoCertificatSam(java.lang.String noCertificatSam) {
      this.noCertificatSam = noCertificatSam;
   }



   public boolean estDansLaBase(String cleDossier)
         throws HibernateException {
      if (dao == null)
         this.setDao(new AvinfogeDAO());
      List l = this.getDao().find(cleDossier);
      if (l!=null)
         return true;
      return false;

   }

   public AvinfogeDAO getDao() {
      return dao;
   }

   public void setDao(AvinfogeDAO dao) {
      this.dao = dao;
   }

   @Override
   public int hashCode() {
      final int PRIME = 31;
      int result = 1;
      result = PRIME * result
            + ((doubleAss == null) ? 0 : doubleAss.hashCode());
      
      result = PRIME * result + ((dtModif == null) ? 0 : dtModif.hashCode());
      result = PRIME * result
            + ((groupeClient == null) ? 0 : groupeClient.hashCode());
      result = PRIME * result + ((id == null) ? 0 : id.hashCode());
      result = PRIME * result
            + ((idAccident == null) ? 0 : idAccident.hashCode());
      result = PRIME * result + ((idUser == null) ? 0 : idUser.hashCode());
      
      result = PRIME * result
            + ((noCertificatSam == null) ? 0 : noCertificatSam.hashCode());
      
      return result;
   }

   @Override
   public boolean equals(Object obj) {
      if (this == obj)
         return true;
      if (obj == null)
         return false;
      if (getClass() != obj.getClass())
         return false;
      final BaseAvinfoge other = (BaseAvinfoge) obj;
      if (dao == null) {
         if (other.dao != null)
            return false;
      } else if (!dao.equals(other.dao))
         return false;
      if (doubleAss == null) {
         if (other.doubleAss != null)
            return false;
      } else if (!doubleAss.equals(other.doubleAss))
         return false;
      
      if (dtModif == null) {
         if (other.dtModif != null)
            return false;
      } else if (!dtModif.equals(other.dtModif))
         return false;
      if (groupeClient == null) {
         if (other.groupeClient != null)
            return false;
      } else if (!groupeClient.equals(other.groupeClient))
         return false;
      if (id == null) {
         if (other.id != null)
            return false;
      } else if (!id.equals(other.id))
         return false;
      if (idAccident == null) {
         if (other.idAccident != null)
            return false;
      } else if (!idAccident.equals(other.idAccident))
         return false;
      if (idUser == null) {
         if (other.idUser != null)
            return false;
      } else if (!idUser.equals(other.idUser))
         return false;
      
      if (noCertificatSam == null) {
         if (other.noCertificatSam != null)
            return false;
      } else if (!noCertificatSam.equals(other.noCertificatSam))
         return false;
      
      return true;
   }

}


and the id class AvinfogeId
Code:
package pojo;

import java.io.Serializable;

public class AvinfogeId implements Serializable {
   /**
    *
    */
   private static final long serialVersionUID = -5624859234341440063L;

   private Integer dtEvenement;

   private String noDossier;

   private String noCertificat;

   private String noGroupe;

   public static long getSerialVersionUID() {
      return serialVersionUID;
   }

   public Integer getDtEvenement() {
      return dtEvenement;
   }

   public void setDtEvenement(Integer dtEvenement) {
      this.dtEvenement = dtEvenement;
   }

   public String getNoCertificat() {
      return noCertificat;
   }

   public void setNoCertificat(String noCertificat) {
      this.noCertificat = noCertificat;
   }

   public String getNoDossier() {
      return noDossier;
   }

   public void setNoDossier(String noDossier) {
      this.noDossier = noDossier;
   }

   public String getNoGroupe() {
      return noGroupe;
   }

   public void setNoGroupe(String noGroupe) {
      this.noGroupe = noGroupe;
   }

   @Override
   public int hashCode() {
      final int PRIME = 31;
      int result = 1;
      result = PRIME * result + ((noCertificat == null) ? 0 : noCertificat.hashCode());
      result = PRIME * result + ((noDossier == null) ? 0 : noDossier.hashCode());
      result = PRIME * result + ((noGroupe == null) ? 0 : noGroupe.hashCode());
      return result;
   }

   @Override
   public boolean equals(Object obj) {
      if (this == obj)
         return true;
      if (obj == null)
         return false;
      if (getClass() != obj.getClass())
         return false;
      final AvinfogeId other = (AvinfogeId) obj;
      
      if (noCertificat == null) {
         if (other.noCertificat != null)
            return false;
      } else if (!noCertificat.equals(other.noCertificat))
         return false;
      if (noDossier == null) {
         if (other.noDossier != null)
            return false;
      } else if (!noDossier.equals(other.noDossier))
         return false;
      if (noGroupe == null) {
         if (other.noGroupe != null)
            return false;
      } else if (!noGroupe.equals(other.noGroupe))
         return false;
      return true;
   }

   

}



Top
 Profile  
 
 Post subject:
PostPosted: Sat Feb 07, 2009 8:25 am 
Regular
Regular

Joined: Thu Sep 06, 2007 2:22 am
Posts: 108
Location: Noida,India
Hi,

Please make sure Avinforge.hbm.xml is place next to hibernate.cfg.xml (As <mapping resource="relative path of hbm file"/> element has value "Avinfoge.hbm.xml")

In Avinfoge.hbm.xml file, <composite-id> element's class attribute says that AvinfigeId class pakage is ca.canassistance.pojo while packege defination on the source code of AvinfigeId class says- this class in pojo package.That means something is wrong there.

Check same thing for BaseAvinfoge class also.
- Source code indicate package = pojo
-- hbm files indicate package = ca.canassistance.pojo
___________________________________________
if it helps you, please rate the post.


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