-->
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.  [ 3 posts ] 
Author Message
 Post subject: transactions disapearing - Rollback implicit
PostPosted: Thu Sep 22, 2005 11:31 am 
Newbie

Joined: Thu Sep 22, 2005 10:52 am
Posts: 2
Friends,

I developed an system to import data from a text file. Each transaction store sales information in one table and sale itens in another. I have foreign key between then.

These information are in one object that have sale information itself and collection with sale itens.

I open a new hibernate transaction, save my object (sale) and commit it.

I Look in JBoss console the generated inserts. During the proccess I can execute a dirty read select from the sales and itens tables and see the new record generated, until the commit. When it occours, these records disapear and in JBoss log I have the information that these records are commited in the database.

When the transaction finish, nothing had been inserted none of tables.

None error messages are received
There is no delete command in the program
Tere is no Rollback command in the program

Tecnical information
- JBoss 4.0
- Hibernate 3
- Database Informix IBM Informix Dynamic Server Version 9.40.FC6
- IBM Informix® Java Database Connectivity 3.00.JC1

Finally, when I reduced the amouth of sales inside the text file to be imported everything works wonderfully, however when I increase the number of sales, there is an error, nothing is stored in the database when I commited and no long transaction warning, no timeout, nothing else.

Anybody can help me??

Tanks.

Carlos


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 22, 2005 12:38 pm 
Senior
Senior

Joined: Thu Aug 04, 2005 4:54 am
Posts: 153
Location: Birmingham, UK
Post mappings, config and code. We can't help without that information.


Top
 Profile  
 
 Post subject: Information
PostPosted: Thu Sep 22, 2005 1:36 pm 
Newbie

Joined: Thu Sep 22, 2005 10:52 am
Posts: 2
Sale.xml
Code:
<?xml version="1.0" encoding="UTF-8"?>

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

<hibernate-mapping
>
    <class
        name="entidades.Venda"
        table="venda"
    >

        <id
            name="codigo"
            column="cod_venda"
            type="int"
        >
            <generator class="increment">
            </generator>
        </id>


   // other implementancion

        <set
            name="itens"
            lazy="true"
            inverse="true"
            cascade="all-delete-orphan"
            sort="unsorted"
        >

            <key
                column="cod_venda"
            >
            </key>

            <one-to-many
                  class="entidades.VendaItem"
            />

        </set>


    </class>

</hibernate-mapping>



SaleItems
Code:
<?xml version="1.0" encoding="UTF-8"?>

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

<hibernate-mapping
>
    <class
        name="entidades.VendaItem"
        table="item_venda"
    >

        <composite-id
            name="id"
            class="entidades.VendaItemPK"
        >

                    <key-many-to-one
                        name="venda"
                        class="entidades.Venda"
                        column="cod_venda"
                    />

                     <key-property
                        name="codItem"
                        type="int"
                        column="cod_item"
                />

        </composite-id>


   // other implementacions

    </class>

</hibernate-mapping>


MyProgram
Code:
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Collection;
import java.util.Hashtable;
import java.util.Iterator;

import javax.ejb.EJBException;

import org.hibernate.HibernateException;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.Transaction;
import org.jboss.naming.Util;

import biblioteca.arquivos.ManipulaArquivo;
import entidades.Caixa;
import entidades.CaixaOperador;
import entidades.Funcionario;
import entidades.Troca;
import entidades.Venda;
import entidades.VendaItem;
import entidades.VendaItemPK;

public class Teste {

   private static final String SESSION_FACTORY_NAME = "java:/hibernate/SessionFactory";
   
   // other implementacions
   
   /**
    *
    * @ejb.interface-method view-type = "remote"
    *
    * @throws EJBException
    *             Thrown if method fails due to system-level error.
    * 
    */
   public void salvar(File arquivo, Calendar dataMovimento, int loja) throws FileNotFoundException, IOException {


      Hashtable movimento = ManipulaArquivo.Carregar(arquivo);

      Populuns p = new Populuns();
     
      Venda v = null;
     
      // Varre todo o arquivo gravando linha a linha
      for (int x = 0; x < (movimento.size()); x++) {
         
         String linha = ((String) movimento.get(String.valueOf(x)));
         String codigo = linha.substring(0, 2);

         // Início de Venda
         if( codigo.equalsIgnoreCase("05") ) {
            v = new Venda();
            v = (Venda) p.setVariaveis( codigo, v, linha );
         }
   
         // Venda de Item
         else if( codigo.equalsIgnoreCase("06") ) {
            VendaItem i = new VendaItem();
            i = (VendaItem) p.setVariaveis( codigo, i, linha );
            // Criando a PK
            VendaItemPK vipk = new VendaItemPK();
            vipk.setCodItem( v.getItens().size() + 1 );
            vipk.setVenda(v);
            i.setId( vipk );
            // Adiciona a lista para que possa ser gerada a sequencia
            v.getItens().add( p.setVariaveis( codigo, i, linha ) );
         }
         
         // Fim de Venda
         else if( codigo.equalsIgnoreCase("07") ) {
            v = (Venda) p.setVariaveis( codigo, v, linha );
            // Salva
            Session s = getSession();
            Transaction tx = s.beginTransaction();
            s.save(v);
            tx.commit();
         }
         
      }
     
   }
   
   private Session getSession() {
      try {
         SessionFactory sf = (SessionFactory) Util.lookup(
               SESSION_FACTORY_NAME, SessionFactory.class);
         return sf.getCurrentSession();
      } catch (HibernateException e) {
         throw e;
      } catch (Exception e) {
         throw new HibernateException("Unable to locate current session", e);
      }
   }

   
}



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