-->
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: Cannot save data into InnoDB table.
PostPosted: Wed Aug 30, 2006 9:58 pm 
Newbie

Joined: Thu Aug 03, 2006 6:54 pm
Posts: 16
For some reason I cannot save data into my InnoDB tables via hibernate. The InnoDB tables are being created properly, however when I execute my transaction the data does not get saved. If I manually insert the data via phpMyAdmin then it works perfectly. Im not sure what I am missing.

Here is my java code:
Code:
Customer ctmr = new Customer("John", "Doe");
ctmr.setcid(1);  //Set customer ID

Fintrans fts = new Fintrans();
fts.setAmountWillingToPay(12000.05);
fts.setCustomer(ctmr);
fts.setDatetime("06/22/2006");
fts.setGrandTotalAccrued(3213.20);
fts.setGrandTotalPaid(13651.10);
fts.setReason("No reason given");

Transaction tx = null;
       
try{
    tx = factory.openSession().beginTransaction();
    Session session = factory.getCurrentSession();
    session.save(fts);
    tx.commit();
}catch(Exception e){
    if (tx!=null)
        tx.rollback();
    throw e;
}


I have two tables on the same database - customer and fintrans. The fintrans table has a foreign key to the customer table (cid).

Here is my Hibernate.cfg.xml file:
Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-configuration PUBLIC
       "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
          "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">

<hibernate-configuration>
   <session-factory>
      <property name="connection.url">zzzzzzz</property>
      <property name="connection.username">zzzzzz</property>
      <property name="connection.driver_class">com.mysql.jdbc.Driver</property>
      <property name="dialect">org.hibernate.dialect.MySQLInnoDBDialect</property>
      <property name="connection.password">zzzzz</property>
      <property name="connection.pool_size">10</property>

      <property name="transaction.factory_class">org.hibernate.transaction.JTATransactionFactory</property>

       <property name="current_session_context_class">org.hibernate.context.JTASessionContext</property>

   
      <property name="transaction.manager_lookup_class">org.hibernate.transaction.SunONETransactionManagerLookup</property>

      <property name="jta.UserTransaction">java:comp/UserTransaction</property>

       <!-- this will show us all sql statements -->
       <property name="hibernate.show_sql">true</property>
   
       <!-- this will create the database tables for us -->
       <property name="hibernate.hbm2ddl.auto">update</property>
           
   </session-factory>
</hibernate-configuration>


If anyone can provide help on the matter that would be much appreciated.

Outlaw.


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.