-->
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.  [ 2 posts ] 
Author Message
 Post subject: Nothing after ... foreign key constraints (Stripped down)
PostPosted: Tue Oct 19, 2004 3:22 pm 
Newbie

Joined: Mon Sep 13, 2004 4:00 pm
Posts: 15
Location: WI
Sorry for making a new post, but I have stripped down my mapping file and classes, and am still getting no output from my program.

Hibernate version:
2.1

Mapping documents:

This document works:
Code:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 2.0//EN"
                                   "http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">
<hibernate-mapping schema="ADMSTDDE">
    <class name="Client" table="DEXA010T">
        <id column="CLIENT_ID" name="id" type="string">
            <generator class="assigned"/>
        </id>
        <property column="NAME" name="name" type="string"/>
    </class>
</hibernate-mapping>


I don't get anything clients to print at all, by just adding the ClientGroup to the mapping file....there is no code change at all:

Code:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 2.0//EN"
                                   "http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">
<hibernate-mapping schema="ADMSTDDE">
    <class name="Client" table="DEXA010T">
        <id column="CLIENT_ID" name="id" type="string">
            <generator class="assigned"/>
        </id>
        <property column="NAME" name="name" type="string"/>
    </class>
    <class name="ClientGroup" table="DEXA020T">
        <id column="CLIENT_GROUP_ID" name="id" type="integer">
            <generator class="sequence"/>
        </id>
    </class>
</hibernate-mapping>


Code between sessionFactory.openSession() and session.close():
Code:
Session session = sessionFactory.openSession();
Transaction tx = session.beginTransaction();
                   
List result = session.find("from Client");
       
for (int i = 0; i<result.size(); i++) {
   Client theClient = (Client) result.get(i);
   System.out.println("Client id: " + theClient.getId() + " Name: " + theClient.getName());
}
System.out.println("\n" + result.size() + " Clients.");
                
tx.commit();
sessionFactory.close();


Here is Client.java:
Code:
public class Client {
   private String id = null;
   private String name = null;
   private List clientGroups = new ArrayList();
// Getters and Setters below
}

Here is ClientGroup.java:
Code:
public class ClientGroup {
   protected int id;
   private Client client = null;
   private String name = null;
// Getter and Setters below;
}

Full stack trace of any exception that occurs:
No exceptions, the program just ends...
Name and version of the database you are using:
DB2
The generated SQL (show_sql=true):
No SQL is generated.
Debug level Hibernate log excerpt:
Code:
13:23:01,704  INFO Environment:469 - Hibernate 2.1.6
13:23:01,714  INFO Environment:503 - loaded properties from resource hibernate.properties: {hibernate.cglib.use_reflection_optimizer=true}
13:23:01,714  INFO Environment:529 - using CGLIB reflection optimizer
13:23:01,714  INFO Environment:540 - JVM does not support Statement.getGeneratedKeys()
13:23:01,714  INFO Environment:551 - JVM does not support LinkedHasMap, LinkedHashSet - ordered maps and sets disabled
13:23:01,724  INFO Environment:554 - using workaround for JVM bug in java.sql.Timestamp
13:23:01,734  INFO Configuration:895 - configuring from resource: /hibernate.cfg.xml
13:23:01,734  INFO Configuration:867 - Configuration resource: /hibernate.cfg.xml
13:23:02,164  INFO Configuration:331 - Mapping resource: cg/partial.hbm.xml
13:23:02,405  INFO Binder:229 - Mapping class: Client -> DEXA010T
13:23:02,485  INFO Binder:229 - Mapping class: ClientGroup -> DEXA020T
13:23:02,485  INFO Configuration:1053 - Configured SessionFactory: null
13:23:02,485  INFO Configuration:627 - processing one-to-many association mappings
13:23:02,485  INFO Configuration:636 - processing one-to-one association property references
13:23:02,485  INFO Configuration:661 - processing foreign key constraints
13:23:02,505  INFO Dialect:82 - Using dialect: net.sf.hibernate.dialect.DB2Dialect
13:23:02,515  INFO SettingsFactory:63 - Use outer join fetching: true
13:23:02,515  INFO DriverManagerConnectionProvider:42 - Using Hibernate built-in connection pool (not for production use!)
13:23:02,515  INFO DriverManagerConnectionProvider:43 - Hibernate connection pool size: 20
13:23:02,665  INFO DriverManagerConnectionProvider:77 - using driver: COM.ibm.db2.jdbc.app.DB2Driver at URL: jdbc:db2:DB2T
13:23:02,665  INFO DriverManagerConnectionProvider:78 - connection properties: {user=VKDB2T2, password=cvet6xsr}
13:23:02,665  INFO TransactionFactoryFactory:31 - Transaction strategy: net.sf.hibernate.transaction.JDBCTransactionFactory
13:23:02,695  INFO TransactionManagerLookupFactory:33 - No TransactionManagerLookup configured (in JTA environment, use of process level read-write cache is not recommended)
13:23:03,316  INFO SettingsFactory:103 - Use scrollable result sets: true
13:23:03,316  INFO SettingsFactory:106 - Use JDBC3 getGeneratedKeys(): false
13:23:03,316  INFO SettingsFactory:109 - Optimize cache for minimal puts: false
13:23:03,316  INFO SettingsFactory:115 - echoing all SQL to stdout
13:23:03,316  INFO SettingsFactory:118 - Query language substitutions: {}
13:23:03,316  INFO SettingsFactory:129 - cache provider: net.sf.hibernate.cache.HashtableCacheProvider
13:23:03,326  INFO Configuration:1116 - instantiating and configuring caches
13:23:03,456  INFO SessionFactoryImpl:118 - building session factory
13:23:03,686  WARN XMLDatabinder:261 - no XSLT implementation found - databinding disabled
13:23:03,686  INFO SessionFactoryObjectFactory:82 - Not binding factory to JNDI, no JNDI name configured
13:23:03,696  INFO Dialect:82 - Using dialect: net.sf.hibernate.dialect.DB2Dialect
13:23:03,696  INFO DriverManagerConnectionProvider:42 - Using Hibernate built-in connection pool (not for production use!)
13:23:03,696  INFO DriverManagerConnectionProvider:43 - Hibernate connection pool size: 20
13:23:03,696  INFO DriverManagerConnectionProvider:77 - using driver: COM.ibm.db2.jdbc.app.DB2Driver at URL: jdbc:db2:DB2T
13:23:03,696  INFO DriverManagerConnectionProvider:78 - connection properties: {user=removed, password=removed}
13:23:03,696  INFO SchemaUpdate:102 - Running hbm2ddl schema update
13:23:03,696  INFO SchemaUpdate:110 - fetching database metadata
13:23:04,337  INFO SchemaUpdate:124 - updating schema
13:23:04,337  INFO Configuration:627 - processing one-to-many association mappings
13:23:04,337  INFO Configuration:636 - processing one-to-one association property references
13:23:04,337  INFO Configuration:661 - processing foreign key constraints


After that there is nothing else in the console. The program will run for a while longer, but it doesn't print any sql, or pull anything back from the database.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Oct 19, 2004 3:34 pm 
Newbie

Joined: Mon Sep 13, 2004 4:00 pm
Posts: 15
Location: WI
As soon as I post this I found a fix. Maybe someone can explain why this was affecting it....

I had this line in my hibernate.cfg.xml:
Code:
<property name="hibernate.hbm2ddl.auto">update</property>


I removed the line, and it worked fine. I really didn't need it (probably copied it from some documentation), but why would that cause the application to quit w/o spitting out any kind of message?


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