-->
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.  [ 9 posts ] 
Author Message
 Post subject: Transaction does't work - Server Timeout ???
PostPosted: Thu Aug 05, 2004 11:09 am 
Newbie

Joined: Mon Aug 02, 2004 8:32 am
Posts: 16
Our problem is that we have no error messages but the Code also does't work and nothing is written into the database.

The Action code:

Code:
/*
******************************************************************************
*
* @file    /vobs/tools/src/tbAdmin/src/com/nokia/testbed/web/RackAction.java
******************************************************************************
*/
package com.nokia.testbed.web;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

import net.sf.hibernate.cfg.Configuration;
import net.sf.hibernate.Session;
import net.sf.hibernate.SessionFactory;
import net.sf.hibernate.Hibernate;
import net.sf.hibernate.HibernateException;
import net.sf.hibernate.Transaction;

import com.nokia.testbed.model.Rack;
import com.nokia.testbed.model.Group;

import java.util.Set;
import java.util.TreeSet;


/*
* Action Class for the Rack
* reads the attributes and makes a decision
*/

public class RackAction extends Action {

    //Attributes
    private String mTarget="success";
    private long idMaingroup;
    private String name=null;
    private int displayOrder;
    private int rackUnits;
    private String description=null;
    private int dummyRack;


  public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response)
  throws IOException, ServletException, Exception {

   
    if(form != null) {
           
        RackForm f = (RackForm)form;
        idMaingroup=f.getIdMaingroup();
        name=f.getName();
        displayOrder=f.getDisplayOrder();
        rackUnits=f.getRackUnits();
        description=f.getDescription();
        dummyRack=f.getDummyRack();
        insertDB();     
    }
   
    // Forward to the appropriate View
    return (mapping.findForward(mTarget));
  }

    private void insertDB() throws Exception{       
        Transaction tx=null;
        Session session=null;
     try{
        Configuration cfg = new Configuration();
        cfg.addClass(Rack.class); 
        cfg.addClass(Group.class); 
       
        SessionFactory sf =cfg.buildSessionFactory();
        session = sf.openSession();

        tx = session.beginTransaction();
        System.out.println("before session.load");
        Group g = (Group)session.load(Group.class,new Long(idMaingroup));
        System.out.println("after session.load");
        Rack r = new Rack();
        r.setName(name);
        r.setDisplayOrder(displayOrder);
        r.setIdMaingroup(idMaingroup);
        r.setRackUnits(rackUnits);
        r.setDescription(description);
        r.setDummyRack(dummyRack);
        r.setGroup(g);
        g.getRack().add(r);
        session.save(r);
        session.flush();
        tx.commit();
     }catch(Exception e){
         if(tx!=null)   
         tx.rollback();
         e.printStackTrace();
         throw e;
      }
      finally{
         if(session!=null)
             session.close();
     }

    }
   

}




The Mappings:

Group.hbm.xml
Code:
<?xml version="1.0"?>
<!--**************************************************************************
-
- @file    /vobs/tools/src/testbed-model/src/com/nokia/testbed/model/Group.hbm.xml
-->

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

    <hibernate-mapping>
        <class  name="com.nokia.testbed.model.Group" table="maingroup">
           
            <id name="idMaingroup" type="long" column="id_maingroup">
                <generator class="sequence">
                    <param name="sequence">maingroup_sequence</param>
                </generator>
            </id>

            <property name="name" column="name" type="string" not-null="true"/>
            <property name="displayOrder" column="display_order" type="integer" not-null="true"/>

            <set name="rack" inverse="true">
                <key column="id_maingroup"/>
                <one-to-many class="com.nokia.testbed.model.Rack"/>
            </set>

        </class>
    </hibernate-mapping>






Rack.hbm.xml

Code:
<?xml version="1.0"?>
<!--**************************************************************************
-
- @file    /vobs/tools/src/testbed-model/src/com/nokia/testbed/model/Rack.hbm.xml
- ***************************************************************************
-->

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

    <hibernate-mapping>
        <class name="com.nokia.testbed.model.Rack" table="Rack">
            <id name="id" type="long" column="id_rack">
                <generator class="sequence">
                    <param name="sequence">rack_sequence</param>
                </generator>
            </id>
           

            <!--<property name="idMaingroup"  column="id_maingroup" type="long" not-null="true" insert="false" update="false" />-->
           
            <property name="name" column="name" type="string" not-null="true"/>
            <property name="displayOrder"  column="display_order" type="int" not-null="true"/>
            <property name="rackUnits"  column="rack_units"  type="int" not-null="true"/>
            <property name="description" type="string"/>
            <property name="dummyRack" column="is_dummy_rack" type="int"/>
            <many-to-one name="group" column="id_maingroup" class="com.nokia.testbed.model.Group" not-null="true"/>
           
        </class>
    </hibernate-mapping>



The logging messages - LOG4J

[code]

2004-08-05 16:43:17,656|Thread-4|DEBUG|net.sf.hibernate.impl.SessionImpl||1 collections initialized

2004-08-05 16:43:17,656|Thread-4|DEBUG|net.sf.hibernate.impl.SessionImpl||collection initialized

2004-08-05 16:43:17,664|Thread-4|DEBUG|net.sf.hibernate.impl.BatcherImpl||about to open: 0 open PreparedStatements, 0 open ResultSets

2004-08-05 16:43:17,664|Thread-4|DEBUG|net.sf.hibernate.SQL||select rack_sequence.nextval from dual

2004-08-05 16:43:17,664|Thread-4|DEBUG|net.sf.hibernate.impl.BatcherImpl||preparing statement

2004-08-05 16:43:17,672|Thread-4|DEBUG|net.sf.hibernate.id.SequenceGenerator||Sequence identifier generated: 28

2004-08-05 16:43:17,672|Thread-4|DEBUG|net.sf.hibernate.impl.BatcherImpl||done closing: 0 open PreparedStatements, 0 open ResultSets

2004-08-05 16:43:17,673|Thread-4|DEBUG|net.sf.hibernate.impl.BatcherImpl||closing statement

2004-08-05 16:43:17,673|Thread-4|DEBUG|net.sf.hibernate.impl.SessionImpl||generated identifier: 28

2004-08-05 16:43:17,674|Thread-4|DEBUG|net.sf.hibernate.impl.SessionImpl||saving [com.nokia.testbed.model.Rack#28]

2004-08-05 16:43:17,684|Thread-4|DEBUG|net.sf.hibernate.impl.SessionImpl||flushing session

2004-08-05 16:43:17,688|Thread-4|DEBUG|net.sf.hibernate.impl.SessionImpl||Collection dirty: [com.nokia.testbed.model.Group.rack#39]

2004-08-05 16:43:17,689|Thread-4|DEBUG|net.sf.hibernate.impl.SessionImpl||Flushing entities and processing referenced collections

2004-08-05 16:43:17,712|Thread-4|DEBUG|net.sf.hibernate.impl.SessionImpl||Collection found: [com.nokia.testbed.model.Group.rack#39], was: [com.nokia.testbed.model.Group.rack#39]

2004-08-05 16:43:17,712|Thread-4|DEBUG|net.sf.hibernate.impl.SessionImpl||Processing unreferenced collections

2004-08-05 16:43:17,713|Thread-4|DEBUG|net.sf.hibernate.impl.SessionImpl||Scheduling collection removes/(re)creates/updates

2004-08-05 16:43:17,726|Thread-4|DEBUG|net.sf.hibernate.impl.SessionImpl||Flushed: 1 insertions, 0 updates, 0 deletions to 2 objects

2004-08-05 16:43:17,726|Thread-4|DEBUG|net.sf.hibernate.impl.SessionImpl||Flushed: 0 (re)creations, 1 updates, 0 removals to 1 collections

2004-08-05 16:43:17,733|Thread-4|DEBUG|net.sf.hibernate.impl.Printer||listing entities:

2004-08-05 16:43:17,738|Thread-4|DEBUG|net.sf.hibernate.impl.Printer||com.nokia.testbed.model.Rack{group=Group#39, displayOrder=2, dummyRack=1, description=nix, name=test, rackUnits=10, id=28}

2004-08-05 16:43:17,743|Thread-4|DEBUG|net.sf.hibernate.impl.Printer||com.nokia.testbed.model.Group{idMaingroup=39, displayOrder=100, rack=[Rack#28], name=drecksgroup}

2004-08-05 16:43:17,744|Thread-4|DEBUG|net.sf.hibernate.impl.SessionImpl||executing flush

2004-08-05 16:43:17,751|Thread-4|DEBUG|net.sf.hibernate.persister.EntityPersister||Inserting entity: [com.nokia.testbed.model.Rack#28]

2004-08-05 16:43:17,832|Thread-4|DEBUG|net.sf.hibernate.impl.BatcherImpl||about to open: 0 open PreparedStatements, 0 open ResultSets

2004-08-05 16:43:17,833|Thread-4|DEBUG|net.sf.hibernate.SQL||insert into Rack (name, display_order, rack_units, description, is_dummy_rack,id_maingroup, id_rack) values (?, ?, ?, ?, ?, ?, ?)

2004-08-05 16:43:17,833|Thread-4|DEBUG|net.sf.hibernate.impl.BatcherImpl||preparing statement

2004-08-05 16:43:17,836|Thread-4|DEBUG|net.sf.hibernate.persister.EntityPersister||Dehydrating entity: [com.nokia.testbed.model.Rack#28]

2004-08-05 16:43:17,836|Thread-4|DEBUG|net.sf.hibernate.type.StringType||binding 'test' to parameter: 1

2004-08-05 16:43:17,837|Thread-4|DEBUG|net.sf.hibernate.type.IntegerType||binding '2' to parameter: 2

2004-08-05 16:43:17,837|Thread-4|DEBUG|net.sf.hibernate.type.IntegerType||binding '10' to parameter: 3

2004-08-05 16:43:17,838|Thread-4|DEBUG|net.sf.hibernate.type.StringType||binding 'nix' to parameter: 4

2004-08-05 16:43:17,838|Thread-4|DEBUG|net.sf.hibernate.type.IntegerType||binding '1' to parameter: 5
[/b]


Our hibernate properties file

[code]
######################
### Query Language ###
######################

## define query language constants / function names

hibernate.query.substitutions true 1, false 0, yes 'Y', no 'N'



#################
### Platforms ###
#################

## JNDI Datasource

#hibernate.connection.datasource jdbc/test
#hibernate.connection.username db2
#hibernate.connection.password db2


## HypersonicSQL

#hibernate.dialect net.sf.hibernate.dialect.HSQLDialect
#hibernate.connection.driver_class org.hsqldb.jdbcDriver
#hibernate.connection.username sa
#hibernate.connection.password
#hibernate.connection.url jdbc:hsqldb:hsql://localhost
#hibernate.connection.url jdbc:hsqldb:test
#hibernate.connection.url jdbc:hsqldb:.


## PostgreSQL

#hibernate.dialect net.sf.hibernate.dialect.PostgreSQLDialect
#hibernate.connection.driver_class org.postgresql.Driver
#hibernate.connection.url jdbc:postgresql:template1
#hibernate.connection.username pg
#hibernate.connection.password
#hibernate.query.substitutions yes 'Y', no 'N'


## DB2

#hibernate.dialect net.sf.hibernate.dialect.DB2Dialect
#hibernate.connection.driver_class COM.ibm.db2.jdbc.app.DB2Driver
#hibernate.connection.url jdbc:db2:test
#hibernate.connection.username db2
#hibernate.connection.password db2


## DB2/400

#hibernate.dialect net.sf.hibernate.dialect.DB2400Dialect
#hibernate.connection.username user
#hibernate.connection.password password

## Native driver
#hibernate.connection.driver_class COM.ibm.db2.jdbc.app.DB2Driver
#hibernate.connection.url jdbc:db2://systemname

## Toolbox driver
#hibernate.connection.driver_class com.ibm.as400.access.AS400JDBCDriver
#hibernate.connection.url jdbc:as400://systemname


## MySQL

#hibernate.dialect net.sf.hibernate.dialect.MySQLDialect
#hibernate.connection.driver_class org.gjt.mm.mysql.Driver
#hibernate.connection.driver_class com.mysql.jdbc.Driver
#hibernate.connection.url jdbc:mysql:///test
#hibernate.connection.username root
#hibernate.connection.password


## Oracle

#hibernate.dialect net.sf.hibernate.dialect.Oracle9Dialect
hibernate.dialect net.sf.hibernate.dialect.OracleDialect
hibernate.connection.driver_class oracle.jdbc.driver.OracleDriver
hibernate.connection.username tbadmin
hibernate.connection.password tbadmin
hibernate.connection.url jdbc:oracle:thin:@localhost:1521:timet


## Sybase

#hibernate.dialect net.sf.hibernate.dialect.SybaseDialect
#hibernate.connection.driver_class com.sybase.jdbc2.jdbc.SybDriver
#hibernate.connection.username sa
#hibernate.connection.password sasasa
#hibernate.connection.url jdbc:sybase:Tds:co3061835-a:5000/tempdb


## Mckoi SQL

#hibernate.dialect net.sf.hibernate.dialect.MckoiDialect
#hibernate.connection.driver_class com.mckoi.JDBCDriver
#hibernate.connection.url jdbc:mckoi:///
#hibernate.connection.url jdbc:mckoi:local://C:/mckoi1.00/db.conf
#hibernate.connection.username admin
#hibernate.connection.password nimda


## SAP DB

#hibernate.dialect net.sf.hibernate.dialect.SAPDBDialect
#hibernate.connection.driver_class com.sap.dbtech.jdbc.DriverSapDB
#hibernate.connection.url jdbc:sapdb://localhost/TST
#hibernate.connection.username TEST
#hibernate.connection.password TEST
#hibernate.query.substitutions yes 'Y', no 'N'


## MS SQL Server

#hibernate.dialect net.sf.hibernate.dialect.SQLServerDialect
#hibernate.connection.username sa
#hibernate.connection.password sa

## JSQL Driver
#hibernate.connection.driver_class com.jnetdirect.jsql.JSQLDriver
#hibernate.connection.url jdbc:JSQLConnect://1E1/test

## JTURBO Driver
#hibernate.connection.driver_class com.newatlanta.jturbo.driver.Driver
#hibernate.connection.url jdbc:JTurbo://1E1:1433/test

## WebLogic Driver
#hibernate.connection.driver_class weblogic.jdbc.mssqlserver4.Driver
#hibernate.connection.url jdbc:weblogic:mssqlserver4:1E1:1433

## Microsoft Driver (not recommended!)
#hibernate.connection.driver_class com.microsoft.jdbc.sqlserver.SQLServerDriver
#hibernate.connection.url jdbc:microsoft:sqlserver://1E1;DatabaseName=test;SelectMethod=cursor

## jTDS
#hibernate.connection.driver_class net.sourceforge.jtds.jdbc.Driver
#hibernate.connection.url jdbc:jtds:sqlserver://1E1/test;SelectMethod=cursor
#hibernate.jdbc.use_scrollable_resultset false

## Interbase

#hibernate.dialect net.sf.hibernate.dialect.InterbaseDialect
#hibernate.connection.username sysdba
#hibernate.connection.password masterkey

## DO NOT specify hibernate.connection.sqlDialect

## InterClient

#hibernate.connection.driver_class interbase.interclient.Driver
#hibernate.connection.url jdbc:interbase://localhost:3060/C:/firebird/test.gdb

## Pure Java

#hibernate.connection.driver_class org.firebirdsql.jdbc.FBDriver
#hibernate.connection.url jdbc:firebirdsql:localhost/3050:/firebird/test.gdb


## Pointbase

#hibernate.dialect net.sf.hibernate.dialect.PointbaseDialect
#hibernate.connection.driver_class com.pointbase.jdbc.jdbcUniversalDriver
#hibernate.connection.url jdbc:pointbase:embedded:sample
#hibernate.connection.username PBPUBLIC
#hibernate.connection.password PBPUBLIC



#################################
### Hibernate Connection Pool ###
#################################

hibernate.connection.pool_size 1



###########################
### C3P0 Connection Pool###
###########################

#hibernate.c3p0.max_size 2
#hibernate.c3p0.min_size 2
#hibernate.c3p0.timeout 5000
#hibernate.c3p0.max_statements 100
#hibernate.c3p0.idle_test_period 3000
#hibernate.c3p0.acquire_increment 2
##hibernate.c3p0.validate false



###################################
### Apache DBCP Connection Pool ###
###################################

## connection pool

#hibernate.dbcp.maxActive 100
#hibernate.dbcp.whenExhaustedAction 1
#hibernate.dbcp.maxWait 120000
#hibernate.dbcp.maxIdle 10

## prepared statement cache

#hibernate.dbcp.ps.maxActive 100
#hibernate.dbcp.ps.whenExhaustedAction 1
#hibernate.dbcp.ps.maxWait 120000
#hibernate.dbcp.ps.maxIdle 10

## optional query to validate pooled connections:

#hibernate.dbcp.validationQuery select 1 from dual
#hibernate.dbcp.testOnBorrow true
#hibernate.dbcp.testOnReturn false



##############################
### Proxool Connection Pool###
##############################

## Properties for external configuration of Proxool

hibernate.proxool.pool_alias pool1

## Only need one of the following

#hibernate.proxool.existing_pool true
#hibernate.proxool.xml proxool.xml
#hibernate.proxool.properties proxool.properties



#################################
### Plugin ConnectionProvider ###
#################################

## use a custom ConnectionProvider (if not set, Hibernate will choose a built-in ConnectionProvider using hueristics)

#hibernate.connection.provider_class net.sf.hibernate.connection.DriverManagerConnectionProvider
#hibernate.connection.provider_class net.sf.hibernate.connection.DatasourceConnectionProvider
#hibernate.connection.provider_class net.sf.hibernate.connection.C3P0ConnectionProvider
#hibernate.connection.provider_class net.sf.hibernate.connection.DBCPConnectionProvider
#hibernate.connection.provider_class net.sf.hibernate.connection.ProxoolConnectionProvider



#######################
### Transaction API ###
#######################

## the Transaction API abstracts application code from the underlying JTA or JDBC transactions

#hibernate.transaction.factory_class net.sf.hibernate.transaction.JTATransactionFactory
#hibernate.transaction.factory_class net.sf.hibernate.transaction.JDBCTransactionFactory


## to use JTATransactionFactory, Hibernate must be able to locate the UserTransaction in JNDI
## default is java:comp/UserTransaction
## you do NOT need this setting if you specify hibernate.transaction.manager_lookup_class

#jta.UserTransaction jta/usertransaction
#jta.UserTransaction javax.transaction.UserTransaction
#jta.UserTransaction UserTransaction


## to use JCS caching with JTA, Hibernate must be able to obtain the JTA TransactionManager

#hibernate.transaction.manager_lookup_class net.sf.hibernate.transaction.JBossTransactionManagerLookup
#hibernate.transaction.manager_lookup_class net.sf.hibernate.transaction.WeblogicTransactionManagerLookup
#hibernate.transaction.manager_lookup_class net.sf.hibernate.transaction.WebSphereTransactionManagerLookup
#hibernate.transaction.manager_lookup_class net.sf.hibernate.transaction.OrionTransactionManagerLookup
#hibernate.transaction.manager_lookup_class net.sf.hibernate.transaction.ResinTransactionManagerLookup



##############################
### Miscellaneous Settings ###
##############################

## print all generated SQL to the console

#hibernate.show_sql true


## auto schema export

#hibernate.hbm2ddl.auto create-drop
#hibernate.hbm2ddl.auto create
#hibernate.hbm2ddl.auto update


## specify a JDBC isolation level

#hibernate.connection.isolation 4


## set the JDBC fetch size

#hibernate.jdbc.fetch_size 25


## set the maximum JDBC 2 batch size (a nonzero value enables batching)

hibernate.jdbc.batch_size 0


## enable use of JDBC 2 scrollable ResultSets (specifying a Dialect will cause Hibernate to use a sensible default)

#hibernate.jdbc.use_scrollable_resultset true


## use streams when writing binary types to / from JDBC

hibernate.jdbc.use_streams_for_binary true


## use JDBC 3 PreparedStatement.getGeneratedKeys to get the identifier of an inserted row

#hibernate.jdbc.use_get_generated_keys true


## specify a default schema for unqualified tablenames

#hibernate.default_schema test


## use a custom stylesheet for XML generation (if not specified, hibernate-default.xslt will be used)

#hibernate.xml.output_stylesheet C:/Hibernate/net/sf/hibernate/hibernate-default.xslt


## enable outerjoin fetching (specifying a Dialect will cause Hibernate to use sensible default)

#hibernate.use_outer_join false


## set the maximum depth of the outer join fetch tree

hibernate.max_fetch_depth 1


## enable CGLIB reflection optimizer (enabled by default)

#hibernate.cglib.use_reflection_optimizer false



##########################
### Second-level Cache ###
##########################

## optimize chache for minimal "puts" instead of minimal "gets" (good for clustered cache)

#hibernate.cache.use_minimal_puts true


## set a prefix for cache region names

hibernate.cache.region_prefix hibernate.test


## enable the query cache

hibernate.cache.use_query_cache true


## choose a cache implementation

hibernate.cache.provider_class net.sf.ehcache.hibernate.Provider
#hibernate.cache.provider_class net.sf.hibernate.cache.EmptyCacheProvider
#hibernate.cache.provider_class net.sf.hibernate.cache.HashtableCacheProvider
#hibernate.cache.provider_class net.sf.hibernate.cache.TreeCacheProvider
#hibernate.cache.provider_class net.sf.hibernate.cache.OSCacheProvider
#hibernate.cache.provider_class net.sf.hibernate.cache.JCSCacheProvider
#hibernate.cache.provider_class net.sf.hibernate.cache.SwarmCacheProvider



############
### JNDI ###
############

## specify a JNDI name for the SessionFactory

#hibernate.session_factory_name hibernate/session_factory


## Hibernate uses JNDI to bind a name to a SessionFactory and to look up the JTA UserTransaction;
## if hibernate.jndi.* are not specified, Hibernate will use the default InitialContext() which
## is the best approach in an application server

#file system
#hibernate.jndi.class com.sun.jndi.fscontext.RefFSContextFactory
#hibernate.jndi.url file:/

#WebSphere
#hibernate.jndi.class com.ibm.websphere.naming.WsnInitialContextFactory
#hibernate.jndi.url iiop://localhost:900/


[/code]


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 05, 2004 11:12 am 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
The log is irrelevant, please show the next 20 lines.

_________________
JAVA PERSISTENCE WITH HIBERNATE
http://jpwh.org
Get the book, training, and consulting for your Hibernate team.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 05, 2004 11:46 am 
Newbie

Joined: Mon Aug 02, 2004 8:32 am
Posts: 16
the next twenty lines from what???


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 05, 2004 11:52 am 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
I don't think that Hibernate stops at this point. Also set show_sql to true.

_________________
JAVA PERSISTENCE WITH HIBERNATE
http://jpwh.org
Get the book, training, and consulting for your Hibernate team.


Top
 Profile  
 
 Post subject: Logs and Database
PostPosted: Thu Aug 05, 2004 12:28 pm 
Newbie

Joined: Mon Aug 02, 2004 8:32 am
Posts: 16
Catalina Out


INFO: Starting Coyote HTTP/1.1 on port 41407
before session.load
after session.load
before session.load
Hibernate: select group0_.id_maingroup as id_maing1_0_, group0_.name as name0_, group0_.display_order as display_3_0_ from maingroup group0
_ where group0_.id_maingroup=?
before session.load
Hibernate: select group0_.id_maingroup as id_maing1_0_, group0_.name as name0_, group0_.display_order as display_3_0_ from maingroup group0
_ where group0_.id_maingroup=?
Hibernate: select rack0_.id_rack as id_rack__, rack0_.id_maingroup as id_maing7___, rack0_.id_rack as id_rack0_, rack0_.name as name0_, rac
k0_.display_order as display_3_0_, rack0_.rack_units as rack_units0_, rack0_.description as descript5_0_, rack0_.is_dummy_rack as is_dummy6
_0_, rack0_.id_maingroup as id_maing7_0_ from Rack rack0_ where rack0_.id_maingroup=?
after session.load
Hibernate: select rack_sequence.nextval from dual
Hibernate: insert into Rack (name, display_order, rack_units, description, is_dummy_rack, id_maingroup, id_rack) values (?, ?, ?, ?, ?, ?,
?)
Hibernate: select rack0_.id_rack as id_rack__, rack0_.id_maingroup as id_maing7___, rack0_.id_rack as id_rack0_, rack0_.name as name0_, rac
k0_.display_order as display_3_0_, rack0_.rack_units as rack_units0_, rack0_.description as descript5_0_, rack0_.is_dummy_rack as is_dummy6
_0_, rack0_.id_maingroup as id_maing7_0_ from Rack rack0_ where rack0_.id_maingroup=?
after session.load
Hibernate: select rack_sequence.nextval from dual
Hibernate: insert into Rack (name, display_order, rack_units, description, is_dummy_rack, id_maingroup, id_rack) values (?, ?, ?, ?, ?, ?,
?)
before session.load
Hibernate: select group0_.id_maingroup as id_maing1_0_, group0_.name as name0_, group0_.display_order as display_3_0_ from maingroup group0
_ where group0_.id_maingroup=?
Hibernate: select rack0_.id_rack as id_rack__, rack0_.id_maingroup as id_maing7___, rack0_.id_rack as id_rack0_, rack0_.name as name0_, rac
k0_.display_order as display_3_0_, rack0_.rack_units as rack_units0_, rack0_.description as descript5_0_, rack0_.is_dummy_rack as is_dummy6
_0_, rack0_.id_maingroup as id_maing7_0_ from Rack rack0_ where rack0_.id_maingroup=?
after session.load
Hibernate: select rack_sequence.nextval from dual
Hibernate: insert into Rack (name, display_order, rack_units, description, is_dummy_rack, id_maingroup, id_rack) values (?, ?, ?, ?, ?, ?,
?)


Log4J Log ... alwas stops after binding'31' to parameter: 7

Code:
2004-08-05 18:21:42,584|Thread-2|DEBUG|net.sf.hibernate.impl.SessionImpl||Processing unreferenced collections
2004-08-05 18:21:42,585|Thread-2|DEBUG|net.sf.hibernate.impl.SessionImpl||Scheduling collection removes/(re)creates/updates
2004-08-05 18:21:42,585|Thread-2|DEBUG|net.sf.hibernate.impl.SessionImpl||Flushed: 1 insertions, 0 updates, 0 deletions to 2 objects
2004-08-05 18:21:42,585|Thread-2|DEBUG|net.sf.hibernate.impl.SessionImpl||Flushed: 0 (re)creations, 1 updates, 0 removals to 1 collections
2004-08-05 18:21:42,586|Thread-2|DEBUG|net.sf.hibernate.impl.Printer||listing entities:
2004-08-05 18:21:42,586|Thread-2|DEBUG|net.sf.hibernate.impl.Printer||com.nokia.testbed.model.Rack{group=Group#39, displayOrder=1, dummyRac
k=1, description=mydescription, name=testname, rackUnits=10, id=31}
2004-08-05 18:21:42,587|Thread-2|DEBUG|net.sf.hibernate.impl.Printer||com.nokia.testbed.model.Group{idMaingroup=39, displayOrder=100, rack=
[Rack#31], name=drecksgroup}
2004-08-05 18:21:42,587|Thread-2|DEBUG|net.sf.hibernate.impl.SessionImpl||executing flush
2004-08-05 18:21:42,588|Thread-2|DEBUG|net.sf.hibernate.persister.EntityPersister||Inserting entity: [com.nokia.testbed.model.Rack#31]
2004-08-05 18:21:42,588|Thread-2|DEBUG|net.sf.hibernate.impl.BatcherImpl||about to open: 2 open PreparedStatements, 0 open ResultSets
2004-08-05 18:21:42,588|Thread-2|DEBUG|net.sf.hibernate.SQL||insert into Rack (name, display_order, rack_units, description, is_dummy_rack,
id_maingroup, id_rack) values (?, ?, ?, ?, ?, ?, ?)
2004-08-05 18:21:42,589|Thread-2|DEBUG|net.sf.hibernate.impl.BatcherImpl||preparing statement
2004-08-05 18:21:42,591|Thread-2|DEBUG|net.sf.hibernate.persister.EntityPersister||Dehydrating entity: [com.nokia.testbed.model.Rack#31]
2004-08-05 18:21:42,591|Thread-2|DEBUG|net.sf.hibernate.type.StringType||binding 'testname' to parameter: 1
2004-08-05 18:21:42,592|Thread-2|DEBUG|net.sf.hibernate.type.IntegerType||binding '1' to parameter: 2
2004-08-05 18:21:42,592|Thread-2|DEBUG|net.sf.hibernate.type.IntegerType||binding '10' to parameter: 3
2004-08-05 18:21:42,593|Thread-2|DEBUG|net.sf.hibernate.type.StringType||binding 'mydescription' to parameter: 4
2004-08-05 18:21:42,593|Thread-2|DEBUG|net.sf.hibernate.type.IntegerType||binding '1' to parameter: 5
2004-08-05 18:21:42,594|Thread-2|DEBUG|net.sf.hibernate.type.LongType||binding '39' to parameter: 6
2004-08-05 18:21:42,594|Thread-2|DEBUG|net.sf.hibernate.type.LongType||binding '31' to parameter: 7



My Tables:


Code:
/*
##################### TABLE MAINGROUP ######################
*/
create table maingroup(
id_maingroup number(38) not null PRIMARY KEY,
name varchar(100) not null,
display_order number(5) not null
);

create SEQUENCE maingroup_sequence
   START WITH 1
   INCREMENT BY 1;



/*
##################### TABLE RACK ######################
*/
create table rack(
id_rack number(38) not null PRIMARY KEY,
id_maingroup number(38) not null,
name varchar(50) not null,
display_order number(5) not null,
rack_units number(5) not null,
description varchar(100),
is_dummy_rack number(1) DEFAULT 0,
constraint fk_id_maingroup foreign key (id_maingroup) references maingroup (id_maingroup)
);

create SEQUENCE rack_sequence
   START WITH 1
   INCREMENT BY 1;



/*


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 05, 2004 12:34 pm 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
No idea, sorry.

Some issues: I hope you don't call buildSessionFactory() every time your Action is called. It is a one-time step, usually executed at application startup. Also, you don't need flush() if you use the Hibernate Transaction API. In this case, you should also set a TransactionFactory in your properties, both are commented out right now. It looks like you have Tomcat, so JDBCTransactionFactory would be appropriate.

_________________
JAVA PERSISTENCE WITH HIBERNATE
http://jpwh.org
Get the book, training, and consulting for your Hibernate team.


Top
 Profile  
 
 Post subject: Hibernate Warnings
PostPosted: Thu Aug 05, 2004 3:00 pm 
Newbie

Joined: Mon Aug 02, 2004 8:32 am
Posts: 16
Are these warnings important for my failure????


2004-08-05 20:16:41,853|Thread-4|WARN |net.sf.ehcache.config.Configurator||No configuration found. Configuring ehcache from ehcache-failsafe.xml found in the classpath: jar:file:/data01/home/ertlb/tomcat/webapps/tbAdmin/WEB-INF/lib/ehcache-0.7.jar!/ehcache-failsafe.xml

2004-08-05 20:16:41,899|Thread-4|WARN |net.sf.ehcache.hibernate.Plugin||Could not find configuration for net.sf.hibernate.cache.UpdateTimestampsCache. Configuring using the defaultCache settings.

2004-08-05 20:16:41,960|Thread-4|WARN |net.sf.ehcache.hibernate.Plugin||Could not find configuration for net.sf.hibernate.cache.QueryCache. Configuring using the defaultCache settings.]


Catalina out always stops here - Maybe it is a Tomcat problem ... it never stops processing the request and in the end there is a timeout message.... it's only when i want to create this child Object Rack. The parent object creation with Hibernate works fine, but the child does'nt...


Code:
Aug 5, 2004 8:15:21 PM org.apache.commons.modeler.Registry loadRegistry
INFO: Loading registry information
Aug 5, 2004 8:15:21 PM org.apache.commons.modeler.Registry getRegistry
INFO: Creating new Registry instance
Aug 5, 2004 8:15:25 PM org.apache.commons.modeler.Registry getServer
INFO: Creating MBeanServer
Aug 5, 2004 8:15:28 PM org.apache.coyote.http11.Http11Protocol init
INFO: Initializing Coyote HTTP/1.1 on port 41407
Starting service Tomcat-Standalone
Apache Tomcat/4.1.27
Aug 5, 2004 8:16:01 PM org.apache.coyote.http11.Http11Protocol start
INFO: Starting Coyote HTTP/1.1 on port 41407
Hibernate: select group0_.id_maingroup as id_maing1_0_, group0_.name as name0_, group0_.display_order as display_3_0_ from maing
roup group0_ where group0_.id_maingroup=?
Hibernate: select rack0_.id_rack as id_rack__, rack0_.id_maingroup as id_maing7___, rack0_.id_rack as id_rack0_, rack0_.name as
name0_, rack0_.display_order as display_3_0_, rack0_.rack_units as rack_units0_, rack0_.description as descript5_0_, rack0_.is_d
ummy_rack as is_dummy6_0_, rack0_.id_maingroup as id_maing7_0_ from Rack rack0_ where rack0_.id_maingroup=?
Hibernate: select rack_sequence.nextval from dual
Hibernate: insert into Rack (name, display_order, rack_units, description, is_dummy_rack, id_maingroup, id_rack) values (?, ?, ?
, ?, ?, ?, ?)


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 05, 2004 3:02 pm 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
The warnings are OK, but you should correct them at some point. Try switching to a different database pool, like C3P0. The builtin connection pool shouldn't be used in production, only for testing.

_________________
JAVA PERSISTENCE WITH HIBERNATE
http://jpwh.org
Get the book, training, and consulting for your Hibernate team.


Top
 Profile  
 
 Post subject: I fixed the problem
PostPosted: Thu Aug 05, 2004 3:30 pm 
Newbie

Joined: Mon Aug 02, 2004 8:32 am
Posts: 16
Thank you for your help!

My problem was one of the following:

Solution possibility 1:
1) I hat other tables linked to my table RACK which have the PRIMARY KEY of RACK as their FOREIGN KEY and so i dropped that tables and now it works.... (I also hat Constraints on these tables...)

Solution possibility 2:
I dropped all tables in the Database and created them again and so all also the entries to the table maingroup which I hat done with the working Hibernate Class where I had no child elements were also deleted.
Maybe there was a mismatch ect....

These entries didn't have consistent mappings because I always changed something in the mapping files and in the beans when I wanted to fix the problem and that could also have been responsible for my problem.

Today we bought your E-Book and so I hope to get to know Hibernate better for the next steps in my project!


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