-->
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.  [ 10 posts ] 
Author Message
 Post subject: Dialect Problems?
PostPosted: Fri Nov 04, 2005 11:37 am 
Newbie

Joined: Fri Oct 28, 2005 3:20 pm
Posts: 8
Location: St Louis MO
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

I have mysql-connector-java-3.1.11-bin.jar in my project's classpath. I'm using Eclipse 3.1 and have the Hibernate Tools 3.1-beta1 installed. My classpath has the hibernate3.jar and everything from the /lib directory of the downloaded Hibernate 3.0.5 distro.

My Hibernate Tools-generated hibernate.cfg.xml is as follows:

<?xml version="1.0" encoding="UTF-8"?>
<!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.driver_class">com.mysql.jdbc.Driver</property>
<property name="connection.password">password</property>
<property name="connection.url">jdbc:mysql://localhost:3306/reallm</property>
<property name="connection.username">bob</property>
<property name="dialect">org.hibernate.dialect.MySQLDialect</property>
<property name="connection.pool_size">1</property>
<property name="show_sql">true</property>
<mapping resource="com/reallm/NavMenu.hbm.xml" />
<mapping resource="com/reallm/Menu.hbm.xml" />
<mapping resource="com/reallm/SubMenu.hbm.xml" />
<mapping resource="com/reallm/SubMenuItem.hbm.xml" />
</session-factory>
</hibernate-configuration>

Please help!

Thanks,

Bryan

Hibernate version: 3.0.5

Mapping documents: In loj4j output

Code between sessionFactory.openSession() and session.close():
Session session = sessionFactory.openSession();
Transaction tx = null;
try {//Create the Transaction
tx = session.beginTransaction();

//Create and populate a SubMenuItem object
SubMenuItem subMenuItem = new SubMenuItem("My first test!", "tester","test");

//Add the SubMenuItem object to a SubMenu
HashSet<SubMenuItem> subMenuItemHashSet = new HashSet<SubMenuItem>();
subMenuItemHashSet.add(subMenuItem);
SubMenu subMenu = new SubMenu("Test SubMenu", subMenuItemHa shSet);

//Add the SubMenu to a Menu
HashSet<SubMenu> subMenuHashSet = new HashSet<SubMenu>();
subMenuHashSet.add(subMenu);
Menu menu = new Menu("My Test Menu", subMenuHashSet);

//Add the menu to a NavMenu
HashSet<Menu> menuHashSet = new HashSet<Menu>();
menuHashSet.add(menu);
NavMenu navMenu = new NavMenu("My first test NavMenu", menuHashSet);
session.save(navMenu);
tx.commit();
}
catch(Exception e)
{if(tx != null) {tx.rollback();}
throw e;
}
finally {session.close();}


Full stack trace of any exception that occurs:
09:35:40,796 INFO Environment:464 - Hibernate 3.0.5
09:35:40,796 INFO Environment:477 - hibernate.properties not found
09:35:40,812 INFO Environment:510 - using CGLIB reflection optimizer
09:35:40,812 INFO Environment:540 - using JDK 1.4 java.sql.Timestamp handling
09:35:41,000 INFO Configuration:464 - Mapping resource: com/reallm/SubMenuItem.hbm.xml
09:35:41,609 DEBUG DTDEntityResolver:42 - trying to locate http://hibernate.sourceforge.net/hibern ... ng-3.0.dtd in classpath under org/hibernate/
09:35:41,625 DEBUG DTDEntityResolver:53 - found http://hibernate.sourceforge.net/hibern ... ng-3.0.dtd in classpath
09:35:41,937 INFO HbmBinder:260 - Mapping class: com.reallm.SubMenuItem -> submenuitem
09:35:41,953 DEBUG HbmBinder:1099 - Mapped property: subMenuItemId -> SUBMENUITEM_ID
09:35:41,968 DEBUG HbmBinder:1099 - Mapped property: title -> title
09:35:41,984 DEBUG HbmBinder:1099 - Mapped property: role -> role
09:35:41,984 DEBUG HbmBinder:1099 - Mapped property: action -> action
09:35:41,984 INFO Configuration:464 - Mapping resource: com/reallm/SubMenu.hbm.xml
09:35:41,984 DEBUG DTDEntityResolver:42 - trying to locate http://hibernate.sourceforge.net/hibern ... ng-3.0.dtd in classpath under org/hibernate/
09:35:41,984 DEBUG DTDEntityResolver:53 - found http://hibernate.sourceforge.net/hibern ... ng-3.0.dtd in classpath
09:35:42,093 INFO HbmBinder:260 - Mapping class: com.reallm.SubMenu -> submenu
09:35:42,109 DEBUG HbmBinder:1099 - Mapped property: subMenuId -> SUBMENU_ID
09:35:42,109 DEBUG HbmBinder:1099 - Mapped property: title -> title
09:35:42,125 DEBUG HbmBinder:1099 - Mapped property: subMenuItems
09:35:42,125 INFO Configuration:464 - Mapping resource: com/reallm/Menu.hbm.xml
09:35:42,140 DEBUG DTDEntityResolver:42 - trying to locate http://hibernate.sourceforge.net/hibern ... ng-3.0.dtd in classpath under org/hibernate/
09:35:42,140 DEBUG DTDEntityResolver:53 - found http://hibernate.sourceforge.net/hibern ... ng-3.0.dtd in classpath
09:35:42,218 INFO HbmBinder:260 - Mapping class: com.reallm.Menu -> menu
09:35:42,218 DEBUG HbmBinder:1099 - Mapped property: menuId -> MENU_ID
09:35:42,218 DEBUG HbmBinder:1099 - Mapped property: title -> title
09:35:42,218 DEBUG HbmBinder:1099 - Mapped property: subMenus
09:35:42,234 INFO Configuration:464 - Mapping resource: com/reallm/NavMenu.hbm.xml
09:35:42,234 DEBUG DTDEntityResolver:42 - trying to locate http://hibernate.sourceforge.net/hibern ... ng-3.0.dtd in classpath under org/hibernate/
09:35:42,234 DEBUG DTDEntityResolver:53 - found http://hibernate.sourceforge.net/hibern ... ng-3.0.dtd in classpath
09:35:42,296 INFO HbmBinder:260 - Mapping class: com.reallm.NavMenu -> navmenu
09:35:42,296 DEBUG HbmBinder:1099 - Mapped property: navMenuId -> NAVMENU_ID
09:35:42,296 DEBUG HbmBinder:1099 - Mapped property: title -> title
09:35:42,312 DEBUG HbmBinder:1099 - Mapped property: menus
09:35:42,312 DEBUG Configuration:998 - Preparing to build session factory with filters : {}
09:35:42,312 INFO Configuration:875 - processing extends queue
09:35:42,312 INFO Configuration:879 - processing collection mappings
09:35:42,312 DEBUG HbmBinder:2466 - Second pass for collection: com.reallm.SubMenu.subMenuItems
09:35:42,312 INFO HbmBinder:2041 - Mapping collection: com.reallm.SubMenu.subMenuItems -> submenuitem
09:35:42,328 DEBUG HbmBinder:2482 - Mapped collection key: subMenuId, one-to-many: com.reallm.SubMenuItem
09:35:42,328 DEBUG HbmBinder:2466 - Second pass for collection: com.reallm.Menu.subMenus
09:35:42,328 INFO HbmBinder:2041 - Mapping collection: com.reallm.Menu.subMenus -> submenu
09:35:42,328 DEBUG HbmBinder:2482 - Mapped collection key: menuId, one-to-many: com.reallm.SubMenu
09:35:42,328 DEBUG HbmBinder:2466 - Second pass for collection: com.reallm.NavMenu.menus
09:35:42,328 INFO HbmBinder:2041 - Mapping collection: com.reallm.NavMenu.menus -> menu
09:35:42,328 DEBUG HbmBinder:2482 - Mapped collection key: navMenuId, one-to-many: com.reallm.Menu
09:35:42,328 INFO Configuration:888 - processing association property references
09:35:42,328 INFO Configuration:917 - processing foreign key constraints
09:35:42,328 DEBUG Configuration:964 - resolving reference to class: com.reallm.NavMenu
09:35:42,328 DEBUG Configuration:964 - resolving reference to class: com.reallm.Menu
09:35:42,328 DEBUG Configuration:964 - resolving reference to class: com.reallm.SubMenu
09:35:42,500 WARN UserSuppliedConnectionProvider:23 - No connection properties specified - the user must supply JDBC connections
Exception in thread "main" org.hibernate.HibernateException: database product name cannot be null
at org.hibernate.dialect.DialectFactory.determineDialect(DialectFactory.java:57)
at org.hibernate.dialect.DialectFactory.buildDialect(DialectFactory.java:39)
at org.hibernate.cfg.SettingsFactory.determineDialect(SettingsFactory.java:374)
at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:110)
at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:1463)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1004)
at com.reallm.NavMenuTest.main(NavMenuTest.java:20)


Name and version of the database you are using: MySQL 5.0

The generated SQL (show_sql=true):none

Debug level Hibernate log excerpt:please see above

_________________
Fate is a collection of decisions


Top
 Profile  
 
 Post subject: BTW
PostPosted: Fri Nov 04, 2005 11:46 am 
Newbie

Joined: Fri Oct 28, 2005 3:20 pm
Posts: 8
Location: St Louis MO
I just wanted to add a little adendum to my post: I have done a LOT of research on this. I am sure it is a simple error on my part and not a problem with Hibernate at all. I also am more than willing to RTFM, I just don't know where to look. I am very new to Hibernate, but have read through Hibernate In Action and loved it!
I really, really appreciate any help you can give me. I totally believe in Open Source and Professional Open Source. I simply do not have the money to pay for professional support right now.
I don't mean to be going overboard, but I submitted a post a couple days ago and it wasn't answered. I really need help and simply want to do everything within reason I can do to get it.
I'll repeat: If it's a simple answer I can find myself, just point me in the right direction.

Thanks for Hibernate, and thanks for your help.

Bryan

_________________
Fate is a collection of decisions


Top
 Profile  
 
 Post subject:
PostPosted: Fri Nov 04, 2005 12:14 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
are you sure that hibernate.cfg.xml is being read by hibernate ?

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Fri Nov 04, 2005 12:56 pm 
Newbie

Joined: Fri Oct 28, 2005 3:20 pm
Posts: 8
Location: St Louis MO
Thanks for your help!

That actually jogged my memory!

I had the Configuration object set up wrong. My line was:
Configuration config = new Configuration();

I changed it to:
Configuration config = new Configuration().configure().setProperties(System.getProperties());

Thank you!

I do have another problem now, though. I get This error:

Exception in thread "main" org.hibernate.MappingException: Error reading resource: com/reallm/SubMenuItem.hbm.xml
at org.hibernate.cfg.Configuration.addClass(Configuration.java:471)
at com.reallm.NavMenuTest.main(NavMenuTest.java:14)
Caused by: org.hibernate.MappingException: duplicate import: com.reallm.SubMenuItem
at org.hibernate.cfg.Mappings.addImport(Mappings.java:105)
at org.hibernate.cfg.HbmBinder.bindPersistentClassCommonValues(HbmBinder.java:541)
at org.hibernate.cfg.HbmBinder.bindClass(HbmBinder.java:488)
at org.hibernate.cfg.HbmBinder.bindRootClass(HbmBinder.java:234)
at org.hibernate.cfg.HbmBinder.bindRoot(HbmBinder.java:152)
at org.hibernate.cfg.Configuration.add(Configuration.java:362)
at org.hibernate.cfg.Configuration.addInputStream(Configuration.java:400)
at org.hibernate.cfg.Configuration.addClass(Configuration.java:468)


At his line (which immediatly follows the config line):
config.addClass(SubMenuItem.class).addClass(SubMenu.class).addClass(Menu.class).addClass(NavMenu.class);

Again, thank you for your help!

Bryan

_________________
Fate is a collection of decisions


Top
 Profile  
 
 Post subject:
PostPosted: Fri Nov 04, 2005 1:27 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
is com/reallm/SubMenuItem.hbm.xml in your classpath?

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Fri Nov 04, 2005 1:53 pm 
Newbie

Joined: Fri Oct 28, 2005 3:20 pm
Posts: 8
Location: St Louis MO
My project structure is as follows:

thereallm/ {ROOT}

{ROOT}/bin (hibernate.cfg.xml, log4j.properties)
{ROOT}/bin/com
{ROOT}/bin/com/reallm
{ROOT}/bin/com/reallm/ (class files, mapping documents)

{ROOT}/src (hibernate.cfg.xml, log4j.properties)
{ROOT}/src/com
{ROOT}/src/com/reallm
{ROOT}/src/com/reallm/ (source files, mapping documents)

The bin directory is Eclipse's output directory and everything in that tree matches everything in the src tree (except that .java. files are .class, of course).

It doesn't seem like this should make a difference, but I have tried running my test app from the actual .class file instead of the .java file and I get the same error. I am wondering if maybe Hibernate is traversing BOTH trees. Maybe?



I'm sorry for all the debugging output, I tried to format it to make it a little esier to read.

11:19:51,250 INFO Environment:464 - Hibernate 3.0.5
11:19:51,265 INFO Environment:477 - hibernate.properties not found
11:19:51,265 INFO Environment:510 - using CGLIB reflection optimizer
11:19:51,265 INFO Environment:540 - using JDK 1.4 java.sql.Timestamp handling

11:19:51,437 INFO Configuration:1110 - configuring from resource: /hibernate.cfg.xml
11:19:51,437 INFO Configuration:1081 - Configuration resource: /hibernate.cfg.xml

11:19:52,031 DEBUG DTDEntityResolver:42 - trying to locate http://hibernate.sourceforge.net/hibern ... on-3.0.dtd in classpath under org/hibernate/
11:19:52,031 DEBUG DTDEntityResolver:53 - found http://hibernate.sourceforge.net/hibern ... on-3.0.dtd in classpath

11:19:52,125 DEBUG Configuration:1067 - connection.driver_class=com.mysql.jdbc.Driver
11:19:52,125 DEBUG Configuration:1067 - connection.password=password
11:19:52,125 DEBUG Configuration:1067 - connection.url=jdbc:mysql://localhost:3306/reallm
11:19:52,125 DEBUG Configuration:1067 - connection.username=bob
11:19:52,125 DEBUG Configuration:1067 - dialect=org.hibernate.dialect.MySQLDialect
11:19:52,125 DEBUG Configuration:1067 - connection.pool_size=1
11:19:52,125 DEBUG Configuration:1067 - show_sql=true


11:19:52,140 DEBUG Configuration:1262 - null<-org.dom4j.tree.DefaultAttribute@1ea0252 [Attribute: name resource value "com/reallm/NavMenu.hbm.xml"]
11:19:52,140 INFO Configuration:444 - Mapping resource: com/reallm/NavMenu.hbm.xml
11:19:52,140 DEBUG DTDEntityResolver:42 - trying to locate http://hibernate.sourceforge.net/hibern ... ng-3.0.dtd in classpath under org/hibernate/
11:19:52,140 DEBUG DTDEntityResolver:53 - found http://hibernate.sourceforge.net/hibern ... ng-3.0.dtd in classpath
11:19:52,421 INFO HbmBinder:260 - Mapping class: com.reallm.NavMenu -> navmenu
11:19:52,437 DEBUG HbmBinder:1099 - Mapped property: navMenuId -> NAVMENU_ID
11:19:52,468 DEBUG HbmBinder:1099 - Mapped property: title -> title
11:19:52,468 DEBUG HbmBinder:1099 - Mapped property: menus

11:19:52,468 DEBUG Configuration:1262 - null<-org.dom4j.tree.DefaultAttribute@b8c8e6 [Attribute: name resource value "com/reallm/Menu.hbm.xml"]
11:19:52,468 INFO Configuration:444 - Mapping resource: com/reallm/Menu.hbm.xml

11:19:52,484 DEBUG DTDEntityResolver:42 - trying to locate http://hibernate.sourceforge.net/hibern ... ng-3.0.dtd in classpath under org/hibernate/
11:19:52,484 DEBUG DTDEntityResolver:53 - found http://hibernate.sourceforge.net/hibern ... ng-3.0.dtd in classpath
11:19:52,562 INFO HbmBinder:260 - Mapping class: com.reallm.Menu -> menu
11:19:52,562 DEBUG HbmBinder:1099 - Mapped property: menuId -> MENU_ID
11:19:52,562 DEBUG HbmBinder:1099 - Mapped property: title -> title
11:19:52,562 DEBUG HbmBinder:1099 - Mapped property: subMenus

11:19:52,562 DEBUG Configuration:1262 - null<-org.dom4j.tree.DefaultAttribute@c980c9 [Attribute: name resource value "com/reallm/SubMenu.hbm.xml"]
11:19:52,562 INFO Configuration:444 - Mapping resource: com/reallm/SubMenu.hbm.xml
11:19:52,578 DEBUG DTDEntityResolver:42 - trying to locate http://hibernate.sourceforge.net/hibern ... ng-3.0.dtd in classpath under org/hibernate/
11:19:52,578 DEBUG DTDEntityResolver:53 - found http://hibernate.sourceforge.net/hibern ... ng-3.0.dtd in classpath
11:19:52,656 INFO HbmBinder:260 - Mapping class: com.reallm.SubMenu -> submenu
11:19:52,656 DEBUG HbmBinder:1099 - Mapped property: subMenuId -> SUBMENU_ID
11:19:52,656 DEBUG HbmBinder:1099 - Mapped property: title -> title
11:19:52,656 DEBUG HbmBinder:1099 - Mapped property: subMenuItems

11:19:52,656 DEBUG Configuration:1262 - null<-org.dom4j.tree.DefaultAttribute@2a6f16 [Attribute: name resource value "com/reallm/SubMenuItem.hbm.xml"]
11:19:52,656 INFO Configuration:444 - Mapping resource: com/reallm/SubMenuItem.hbm.xml
11:19:52,671 DEBUG DTDEntityResolver:42 - trying to locate http://hibernate.sourceforge.net/hibern ... ng-3.0.dtd in classpath under org/hibernate/
11:19:52,671 DEBUG DTDEntityResolver:53 - found http://hibernate.sourceforge.net/hibern ... ng-3.0.dtd in classpath
11:19:52,734 INFO HbmBinder:260 - Mapping class: com.reallm.SubMenuItem -> submenuitem
11:19:52,734 DEBUG HbmBinder:1099 - Mapped property: subMenuItemId -> SUBMENUITEM_ID
11:19:52,734 DEBUG HbmBinder:1099 - Mapped property: title -> title
11:19:52,734 DEBUG HbmBinder:1099 - Mapped property: role -> role
11:19:52,734 DEBUG HbmBinder:1099 - Mapped property: action -> action
11:19:52,734 INFO Configuration:1222 - Configured SessionFactory: null

11:19:52,734 DEBUG Configuration:1223 - properties: {java.class.path=C:\Documents and Settings\Bryan\workspace\thereallm\bin; more...}

11:19:52,765 INFO Configuration:464 - Mapping resource: com/reallm/SubMenuItem.hbm.xml
11:19:52,781 DEBUG DTDEntityResolver:42 - trying to locate http://hibernate.sourceforge.net/hibern ... ng-3.0.dtd in classpath under org/hibernate/
11:19:52,781 DEBUG DTDEntityResolver:53 - found http://hibernate.sourceforge.net/hibern ... ng-3.0.dtd in classpath

11:19:52,890 ERROR Configuration:365 - Could not compile the mapping document

org.hibernate.MappingException: duplicate import: com.reallm.SubMenuItem
at org.hibernate.cfg.Mappings.addImport(Mappings.java:105)
at org.hibernate.cfg.HbmBinder.bindPersistentClassCommonValues(HbmBinder.java:541)
at org.hibernate.cfg.HbmBinder.bindClass(HbmBinder.java:488)
at org.hibernate.cfg.HbmBinder.bindRootClass(HbmBinder.java:234)
at org.hibernate.cfg.HbmBinder.bindRoot(HbmBinder.java:152)
at org.hibernate.cfg.Configuration.add(Configuration.java:362)
at org.hibernate.cfg.Configuration.addInputStream(Configuration.java:400)
at org.hibernate.cfg.Configuration.addClass(Configuration.java:468)
at com.reallm.NavMenuTest.main(NavMenuTest.java:15)
org.hibernate.MappingException: Error reading resource: com/reallm/SubMenuItem.hbm.xml
at org.hibernate.cfg.Configuration.addClass(Configuration.java:471)
at com.reallm.NavMenuTest.main(NavMenuTest.java:15)
Caused by: org.hibernate.MappingException: duplicate import: com.reallm.SubMenuItem
at org.hibernate.cfg.Mappings.addImport(Mappings.java:105)
at org.hibernate.cfg.HbmBinder.bindPersistentClassCommonValues(HbmBinder.java:541)
at org.hibernate.cfg.HbmBinder.bindClass(HbmBinder.java:488)
at org.hibernate.cfg.HbmBinder.bindRootClass(HbmBinder.java:234)
at org.hibernate.cfg.HbmBinder.bindRoot(HbmBinder.java:152)
at org.hibernate.cfg.Configuration.add(Configuration.java:362)
at org.hibernate.cfg.Configuration.addInputStream(Configuration.java:400)
at org.hibernate.cfg.Configuration.addClass(Configuration.java:468)
... 1 more

Thanks again for your help max.

Bryan

_________________
Fate is a collection of decisions


Top
 Profile  
 
 Post subject:
PostPosted: Fri Nov 04, 2005 1:57 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
i will assume you have two files with the same class or is including the file twice.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Fri Nov 04, 2005 2:01 pm 
Newbie

Joined: Fri Oct 28, 2005 3:20 pm
Posts: 8
Location: St Louis MO
Why would it do that?

_________________
Fate is a collection of decisions


Top
 Profile  
 
 Post subject:
PostPosted: Fri Nov 04, 2005 2:21 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
because you call cfg.addClass()

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Fri Nov 04, 2005 2:51 pm 
Newbie

Joined: Fri Oct 28, 2005 3:20 pm
Posts: 8
Location: St Louis MO
Thanks a lot max, I had a couple other minor issues to deal with - but everything is working now! :-)

Thanks for your time, I'll be sure to give you credit. You've really been a tremendous help.

Bryan

_________________
Fate is a collection of decisions


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