-->
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: Silly Persister Error or Silly User???
PostPosted: Sat Sep 27, 2003 2:22 am 
Newbie

Joined: Sat Sep 27, 2003 2:13 am
Posts: 7
I'm trying to persist a simple object to a MySql database...

My Hibernate.properties...

Quote:
hibernate.connection.username=root
hibernate.connection.password=secret
hibernate.connection.url=jdbc:mysql://localhost/j2tutos
hibernate.connection.driver_class=com.mysql.jdbc.Driver
hibernate.dialect=net.sf.hibernate.dialect.MySQLDialect
hibernate.show_sql=true


My Mapping File (which matches) my object...

Quote:
<hibernate-mapping>
<class name="net.sourceforge.j2tutos.business.products.Product" table="products">
<id name="key" column="id">
<generator class="identity"/>
</id>

<property name="name" column="name"/>
<property name="version" column="version"/>
<property name="description" column="description"/>
<property name="desc1" column="desc1"/>
<property name="desc2" column="desc2"/>
<property name="state" column="state"/>
<property name="path" column="path"/>
<property name="price" column="price"/>
<property name="cost" column="cost"/>
<property name="currency" column="currency"/>

</class>

</hibernate-mapping>


My Java Code...

Quote:
public Result persist(PersisterParm parm) {
HibernatePersisterParm hbmParm = null;
Result result = Result.getDefaultResult();

if (parm instanceof HibernatePersisterParm) {
hbmParm = (HibernatePersisterParm) parm;
try {
getCofiguration().addClass(hbmParm.getClazz());
Session session = getSessionFactory().openSession();
session.saveOrUpdate(hbmParm.getObject());
session.flush();
session.close();
} catch (HibernateException hbe) {
result.setSuccessful(false);
result.addErrorMessage(hbe.getMessage());
}
} else {
result.setSuccessful(false);
}

return result;
}



My result...

Quote:
[INFO] Environment - -Hibernate 2.0.1
[INFO] Environment - -loaded properties from resource hibernate.properties: {hibernate.connection.username=root, hibernate.connection.password=secret, hibernate.cglib.use_reflection_optimizer=true, hibernate.dialect=net.sf.hibernate.dialect.MySQLDialect, hibernate.show_sql=true, hibernate.connection.url=jdbc:mysql://localhost/j2tutos, hibernate.connection.driver_class=com.mysql.jdbc.Driver}
[INFO] Environment - -using CGLIB reflection optimizer
[INFO] Environment - -JVM proxy support: true
.[INFO] SessionFactoryImpl - -building session factory
[INFO] Dialect - -Using dialect: net.sf.hibernate.dialect.MySQLDialect
[INFO] DriverManagerConnectionProvider - -Hibernate connection pool size: 20
[INFO] DriverManagerConnectionProvider - -using driver: com.mysql.jdbc.Driver at URL: jdbc:mysql://localhost/j2tutos
[INFO] DriverManagerConnectionProvider - -connection properties: {user=root, password=shareen2}
[INFO] SessionFactoryImpl - -Use outer join fetching: true
[INFO] SessionFactoryImpl - -Use scrollable result sets: true
[INFO] SessionFactoryImpl - -JDBC 2 max batch size: 15
[INFO] SessionFactoryImpl - -echoing all SQL to stdout
[INFO] SessionFactoryObjectFactory - -no JDNI name configured
[INFO] SessionFactoryImpl - -Query language substitutions: {}
[INFO] Configuration - -Mapping resource: net/sourceforge/j2tutos/business/products/Product.hbm.xml
[INFO] Binder - -Mapping class: net.sourceforge.j2tutos.business.products.Product -> products
No persister for: net.sourceforge.j2tutos.business.products.Product



Best I can tell my Product class and the mapping match. I'm also sure that my object is not null when passed into my method.

Any help apprecieated.

TIA,

Happy


Top
 Profile  
 
 Post subject:
PostPosted: Sat Sep 27, 2003 2:25 am 
Newbie

Joined: Sat Sep 27, 2003 2:13 am
Posts: 7
Additional Info...this is not under Tomcat...strictly trying to test via IDE and JUnit.


Top
 Profile  
 
 Post subject:
PostPosted: Sat Sep 27, 2003 6:27 pm 
Newbie

Joined: Sat Sep 27, 2003 2:13 am
Posts: 7
Bump....anyone?


Top
 Profile  
 
 Post subject:
PostPosted: Sun Sep 28, 2003 2:30 am 
CGLIB Developer
CGLIB Developer

Joined: Thu Aug 28, 2003 1:44 pm
Posts: 1217
Location: Vilnius, Lithuania
HappyPappy wrote:
Bump....anyone?


Looks like there is nothing bad in code, tryto find problem with debuger, it can be caused by class loading in IDE.


Top
 Profile  
 
 Post subject:
PostPosted: Sun Sep 28, 2003 2:51 am 
Newbie

Joined: Sat Sep 27, 2003 2:13 am
Posts: 7
Error happens here:

Quote:
session.saveOrUpdate(hbmParm.getObject());


And all I get back is an (Mapping) Exception with the following message:

Quote:
No persister for: net.sourceforge.j2tutos.business.products.Product


Any way to turn on finer debugging in Hibernate?


Top
 Profile  
 
 Post subject: finer logging in Hibernate
PostPosted: Sun Sep 28, 2003 4:14 am 
Newbie

Joined: Tue Aug 26, 2003 10:17 pm
Posts: 5
Hi,

Usually hibernate will follow whatever log4j settings you have. So if you put a line :

log4j.logger.net.sf.hibernate=DEBUG

in your log4j.properties Hibernate will print out all debugging statements.

Clarence


Top
 Profile  
 
 Post subject:
PostPosted: Tue Sep 30, 2003 2:54 am 
Newbie

Joined: Sat Sep 27, 2003 2:13 am
Posts: 7
Can someone pls help, I've turned on DEBUG using Log4J and I get the output below...still nothing obvious as to what I'm doing wrong...pls help!!!

Thanks,

Un-Happy

Code:
.00:52:00,040  INFO Environment:401 - Hibernate 2.0.1
00:52:00,050  INFO Environment:435 - loaded properties from resource hibernate.properties: {hibernate.connection.username=root, hibernate.connection.password=secret, hibernate.cglib.use_reflection_optimizer=true, hibernate.dialect=net.sf.hibernate.dialect.MySQLDialect, hibernate.show_sql=true, hibernate.connection.url=jdbc:mysql://localhost/j2tutos, hibernate.connection.driver_class=com.mysql.jdbc.Driver}
00:52:00,060  INFO Environment:450 - using CGLIB reflection optimizer
00:52:00,070  INFO Environment:460 - JVM proxy support: true
00:52:00,341  INFO SessionFactoryImpl:140 - building session factory
00:52:00,341 DEBUG SessionFactoryImpl:142 - instantiating session factory with properties: {java.runtime.name=Java(TM) 2 Runtime Environment, Standard Edition, hibernate.connection.password=secret, sun.boot.library.path=D:\java\jdk1.3.1_06\jre\bin, java.vm.version=1.3.1_06-b01, hibernate.connection.username=root, java.vm.vendor=Sun Microsystems Inc., java.vendor.url=http://java.sun.com/, path.separator=;, java.vm.name=Java HotSpot(TM) Client VM, file.encoding.pkg=sun.io, java.vm.specification.name=Java Virtual Machine Specification, user.dir=D:\projects\sourceforge\j2tutos-core, java.runtime.version=1.3.1_06-b01, java.awt.graphicsenv=sun.awt.Win32GraphicsEnvironment, os.arch=x86, java.io.tmpdir=C:\WINXP\TEMP\, line.separator=
, java.vm.specification.vendor=Sun Microsystems Inc., java.awt.fonts=, os.name=Windows XP, java.library.path=D:\java\jdk1.3.1_06\bin;.;C:\WINXP\System32;C:\WINXP;D:\Java\jdk1.3.1_06\bin;D:\Java\ant-1.4.1\bin;D:\Java\maven-1.0-beta-10\bin;D:\ghostscript\gs8.00\bin;D:\Program Files\GNU\WinCvs 1.2;D:\Perl\bin\;C:\WINXP\system32;C:\WINXP;C:\WINXP\System32\Wbem;D:\oracle\ora9iR2\bin;C:\Program Files\Oracle\jre\1.3.1\bin;C:\Program Files\Oracle\jre\1.1.8\bin;C:\Program Files\Microsoft SQL Server\80\Tools\BINN;D:\Program Files\ActiveState Komodo 2.3\;D:\Program Files\Microsoft Visual Studio\Common\MSDev98\Bin;D:\Program Files\Microsoft Visual Studio\Common\Tools;D:\Program Files\Microsoft Visual Studio\VC98\bin;C:\WINXP\system32;C:\WINXP;C:\WINXP\System32\Wbem;C:\Program Files\Internet Explorer;C:\Program Files\UltraEdit, java.specification.name=Java Platform API Specification, java.class.version=47.0, os.version=5.1, user.home=C:\Documents and Settings\mpzarde, user.timezone=America/Denver, java.awt.printerjob=sun.awt.windows.WPrinterJob, file.encoding=Cp1252, java.specification.version=1.3, hibernate.connection.driver_class=com.mysql.jdbc.Driver, user.name=mpzarde, java.class.path=D:\java\IntelliJ-IDEA-3.0.5\lib\junit.jar;D:\java\jdk1.3.1_06\jre\lib\i18n.jar;D:\java\jdk1.3.1_06\jre\lib\jaws.jar;D:\java\jdk1.3.1_06\jre\lib\rt.jar;D:\java\jdk1.3.1_06\jre\lib\sunrsasign.jar;D:\projects\sourceforge\j2tutos-core\target\classes;C:\Documents and Settings\mpzarde\.maven\repository\junit\jars\junit-3.8.1.jar;C:\Documents and Settings\mpzarde\.maven\repository\mysql\jars\mysql-connector-java-2.0.14-bin.jar;D:\projects\sourceforge\hibernate-2.0\lib\ant.jar;D:\projects\sourceforge\hibernate-2.0\lib\c3p0.jar;D:\projects\sourceforge\hibernate-2.0\lib\cglib-asm.jar;D:\projects\sourceforge\hibernate-2.0\lib\commons-beanutils.jar;D:\projects\sourceforge\hibernate-2.0\lib\commons-collections.jar;D:\projects\sourceforge\hibernate-2.0\lib\commons-dbcp.jar;D:\projects\sourceforge\hibernate-2.0\lib\commons-lang.jar;D:\projects\sourceforge\hibernate-2.0\lib\commons-logging.jar;D:\projects\sourceforge\hibernate-2.0\lib\commons-pool.jar;D:\projects\sourceforge\hibernate-2.0\lib\connector.jar;D:\projects\sourceforge\hibernate-2.0\lib\dom4j.jar;D:\projects\sourceforge\hibernate-2.0\hibernate2.jar;D:\projects\sourceforge\hibernate-2.0\lib\jaas.jar;D:\projects\sourceforge\hibernate-2.0\lib\jcs.jar;D:\projects\sourceforge\hibernate-2.0\lib\jdbc2_0-stdext.jar;D:\projects\sourceforge\hibernate-2.0\lib\jta.jar;D:\projects\sourceforge\hibernate-2.0\lib\junit.jar;D:\projects\sourceforge\hibernate-2.0\lib\log4j-1.2.8.jar;D:\projects\sourceforge\hibernate-2.0\lib\odmg.jar;D:\projects\sourceforge\hibernate-2.0\lib\optional.jar;D:\projects\sourceforge\hibernate-2.0\lib\proxool.jar;D:\projects\sourceforge\hibernate-2.0\lib\xalan.jar;D:\projects\sourceforge\hibernate-2.0\lib\xerces.jar;D:\projects\sourceforge\hibernate-2.0\lib\xml-apis.jar;D:\java\IntelliJ-IDEA-3.0.5\lib\idea_rt.jar, hibernate.show_sql=true, java.vm.specification.version=1.0, java.home=D:\java\jdk1.3.1_06\jre, hibernate.connection.url=jdbc:mysql://localhost/j2tutos, hibernate.dialect=net.sf.hibernate.dialect.MySQLDialect, java.specification.vendor=Sun Microsystems Inc., user.language=en, awt.toolkit=sun.awt.windows.WToolkit, java.vm.info=mixed mode, hibernate.cglib.use_reflection_optimizer=true, java.version=1.3.1_06, java.ext.dirs=D:\java\jdk1.3.1_06\jre\lib\ext, sun.boot.class.path=D:\java\jdk1.3.1_06\jre\lib\rt.jar;D:\java\jdk1.3.1_06\jre\lib\i18n.jar;D:\java\jdk1.3.1_06\jre\lib\sunrsasign.jar;D:\java\jdk1.3.1_06\jre\classes, java.vendor=Sun Microsystems Inc., file.separator=\, java.vendor.url.bug=http://java.sun.com/cgi-bin/bugreport.cgi, sun.cpu.endian=little, sun.io.unicode.encoding=UnicodeLittle, user.region=US, sun.cpu.isalist=pentium i486 i386}
00:52:00,391  INFO Dialect:37 - Using dialect: net.sf.hibernate.dialect.MySQLDialect
00:52:00,411  INFO DriverManagerConnectionProvider:41 - Hibernate connection pool size: 20
00:52:00,421  INFO DriverManagerConnectionProvider:70 - using driver: com.mysql.jdbc.Driver at URL: jdbc:mysql://localhost/j2tutos
00:52:00,421  INFO DriverManagerConnectionProvider:71 - connection properties: {user=root, password=secret}
00:52:00,421  INFO SessionFactoryImpl:170 - Use outer join fetching: true
00:52:00,421 DEBUG DriverManagerConnectionProvider:77 - total checked-out connections: 0
00:52:00,421 DEBUG DriverManagerConnectionProvider:90 - opening new JDBC connection
00:52:00,541 DEBUG DriverManagerConnectionProvider:103 - created connection to: jdbc:mysql://localhost/j2tutos, Isolation Level: 2
00:52:00,571 DEBUG DriverManagerConnectionProvider:117 - returning connection to pool, pool size: 1
00:52:00,571  INFO SessionFactoryImpl:193 - Use scrollable result sets: true
00:52:00,571  INFO SessionFactoryImpl:194 - JDBC 2 max batch size: 15
00:52:00,571  INFO SessionFactoryImpl:202 - echoing all SQL to stdout
00:52:01,833 DEBUG SessionFactoryObjectFactory:39 - initializing class SessionFactoryObjectFactory
00:52:01,843 DEBUG SessionFactoryObjectFactory:76 - registered: 402881e5nullf7f1447fnull00f7nullf14485a9null0000 (unnamed)
00:52:01,843  INFO SessionFactoryObjectFactory:82 - no JDNI name configured
00:52:01,843  INFO SessionFactoryImpl:287 - Query language substitutions: {}
00:52:01,843 DEBUG SessionFactoryImpl:302 - instantiated session factory
00:52:01,853  INFO Configuration:283 - Mapping resource: net/sourceforge/j2tutos/business/products/Product.hbm.xml
00:52:02,033 DEBUG DTDEntityResolver:20 - trying to locate http://hibernate.sourceforge.net/hibernate-mapping.dtd in classpath under net/sf/hibernate/
00:52:02,043 DEBUG DTDEntityResolver:25 - http://hibernate.sourceforge.net/hibernate-mapping.dtdnot found in classpath
00:52:02,524  INFO Binder:176 - Mapping class: net.sourceforge.j2tutos.business.products.Product -> j2tutos.products
00:52:02,654 DEBUG Binder:380 - Mapped property: key -> id, type: integer
00:52:02,684 DEBUG Binder:380 - Mapped property: name -> name, type: string
00:52:02,854 DEBUG SessionImpl:428 - opened session
net.sf.hibernate.MappingException: No persister for: net.sourceforge.j2tutos.business.products.Product


Top
 Profile  
 
 Post subject:
PostPosted: Tue Sep 30, 2003 4:21 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
Well, from the log, it looks like you call buildSessionFactory() before you add the mapping to the Configuration.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Sep 30, 2003 10:18 pm 
Newbie

Joined: Sat Sep 27, 2003 2:13 am
Posts: 7
Yep, that fixed it.

I (wrongly) guessed that the configuration could be altered (mappings added, removed, and/or reloaded) after the SessionFactory had been built....any thoughts as to whether this is/should be possible?

Thanks,

Happy


Top
 Profile  
 
 Post subject:
PostPosted: Wed Oct 01, 2003 5:09 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
No! This will never be possible. Hibernate performs well because we use immutable objects all through the code and never need to do synchronization.


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.