-->
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.  [ 6 posts ] 
Author Message
 Post subject: Help in using Annotations rather than a mapping file
PostPosted: Wed Jun 27, 2007 7:47 am 
Newbie

Joined: Mon Jun 25, 2007 12:08 pm
Posts: 8
I've tried two other forums but did not receive an answer. I'm hoping that someone on this forum might be able to help.


I am trying to learn hibernate and am trying to follow the samples in the book "Java Persistence with Hibernate" . The download examples do not include the sample code at this level; before including Entity Manager.

I was able to get HelloWorld working using a mapping file, but when I try to change the code to use Annotations I get the following error:
Code:
Exception in thread "main" org.hibernate.MappingException: Unknown entity: hello.Message


I have created the mappings in the Message.java file (see below).
I have created the mappings in hibernate.cfg.xml and in the sessionFactory.

I am using a MS-SQL database rather than the HSQLDB database which the samples shows. Other than that the code should follow the book.

I tried to include as much information as possible.

Any help or suggestions would be appreciated.

-Steve Nelligan

Hibernate version:
3.2.4 sp1

Mapping documents:
Code:
package hello;

import javax.persistence.*;

/**
* Created by IntelliJ IDEA.
* User: snelligan
* Date: Jun 21, 2007
* Time: 2:34:13 PM
*/
public class Message {

@Id
@GeneratedValue
@Column(name = "MESSAGE_ID")
private Long id;

@Column(name = "MESSAGE_TEXT")
private String text;

@ManyToOne(cascade = CascadeType.ALL)
@JoinColumn(name = "NEXT_MESSAGE_ID")
private Message nextMessage;

protected Message() {}

public Message(String text) {
this.text = text;
}

public Long getId() {
return id;
}
private void setId(Long id) {
this.id = id;
}

public String getText() {
return text;
}
public void setText(String text) {
this.text = text;
}

public Message getNextMessage() {
return nextMessage;
}
public void setNextMessage(Message nextMessage) {
this.nextMessage = nextMessage;
}
}

#############################################
Code:
<!DOCTYPE hibernate-configuration SYSTEM
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">

<hibernate-configuration>
<session-factory>
<property name="hibernate.connection.driver_class">com.microsoft.jdbc.sqlserver.SQLServerDriver</property>
<property name="hibernate.connection.url">jdbc:microsoft:sqlserver://130.126.4.66:1433;databaseName=StevesTesting;SelectMethod=cursor</property>
<property name="hibernate.connection.username">snelliga</property>
<property name="hibernate.connection.password">smn-1812</property>
<property name="hibernate.dialect">org.hibernate.dialect.SQLServerDialect</property>

<!-- Use the C3P0 connection pool provider -->
<property name="hibernate.c3p0.min_size">5</property>
<property name="hibernate.c3p0.max_size">20</property>
<property name="hibernate.c3p0.timeout">300</property>
<property name="hibernate.c3p0.max_statements">50</property>
<property name="hibernate.c3p0.idle_test_period">3000</property>

<!-- Show and print nice SQL on stdout -->
<property name="show_sql">true</property>
<property name="format_sql">true</property>

<!-- List of annotated classes-->
<mapping class="hello.Message"/>

</session-factory>
</hibernate-configuration>


Code between sessionFactory.openSession() and session.close():
Code:
private static SessionFactory sessionFactory;

static {
try {
// AnnotationConfiguration cfg = new AnnotationConfiguration();
// cfg.addAnnotatedClass(hello.Message.class);
// cfg.configure("hibernate.cfg.xml");
// sessionFactory = cfg.buildSessionFactory();
sessionFactory = new AnnotationConfiguration()
.addAnnotatedClass(hello.Message.class)
.configure("hibernate.cfg.xml")
.buildSessionFactory();
}
catch (Throwable ex) {
throw new ExceptionInInitializerError(ex);
}
}

Full stack trace of any exception that occurs:
Code:
07:41:12,103DEBUG DefaultSaveOrUpdateEventListener:158 - saving transient instance
Exception in thread "main" org.hibernate.MappingException: Unknown entity: hello.Message
at org.hibernate.impl.SessionFactoryImpl.getEntityPersister(SessionFactoryImpl.java:550)
at org.hibernate.impl.SessionImpl.getEntityPersister(SessionImpl.java:1338)
at org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:98)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:187)
at org.hibernate.event.def.DefaultSaveEventListener.saveWithGeneratedOrRequestedId(DefaultSaveEventListener.java:33)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:172)
at org.hibernate.event.def.DefaultSaveEventListener.performSaveOrUpdate(DefaultSaveEventListener.java:27)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:70)
at org.hibernate.impl.SessionImpl.fireSave(SessionImpl.java:535)
at org.hibernate.impl.SessionImpl.save(SessionImpl.java:523)
at org.hibernate.impl.SessionImpl.save(SessionImpl.java:519)
at hello.HelloWorld.main(HelloWorld.java:24)


Name and version of the database you are using:
MS-SQL

Debug level Hibernate log excerpt:
Code:
07:41:04,702 INFO Version:15 - Hibernate Annotations 3.3.0.GA
07:41:04,732 INFO Environment:514 - Hibernate 3.2.4.sp1
07:41:04,732 INFO Environment:547 - hibernate.properties not found
07:41:04,742 INFO Environment:681 - Bytecode provider name : cglib
07:41:04,742 INFO Environment:598 - using JDK 1.4 java.sql.Timestamp handling
07:41:04,862 INFO Configuration:1426 - configuring from resource: hibernate.cfg.xml
07:41:04,862 INFO Configuration:1403 - Configuration resource: hibernate.cfg.xml
07:41:04,973DEBUG DTDEntityResolver:38 - trying to resolve system-id [http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd]
07:41:04,973DEBUG DTDEntityResolver:40 - recognized hibernate namespace; attempting to resolve on classpath under org/hibernate/
07:41:04,983DEBUG DTDEntityResolver:50 - located [http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd] in classpath
07:41:05,033DEBUG Configuration:1387 - hibernate.connection.driver_class=com.microsoft.jdbc.sqlserver.SQLServerDriver
07:41:05,033DEBUG Configuration:1387 - hibernate.connection.url=jdbc:microsoft:sqlserver://130.126.4.66:1433;databaseName=StevesTesting;SelectMethod=cursor
07:41:05,033DEBUG Configuration:1387 - hibernate.connection.username=snelliga
07:41:05,033DEBUG Configuration:1387 - hibernate.connection.password=smn-1812
07:41:05,033DEBUG Configuration:1387 - hibernate.dialect=org.hibernate.dialect.SQLServerDialect
07:41:05,033DEBUG Configuration:1387 - hibernate.c3p0.min_size=5
07:41:05,033DEBUG Configuration:1387 - hibernate.c3p0.max_size=20
07:41:05,043DEBUG Configuration:1387 - hibernate.c3p0.timeout=300
07:41:05,043DEBUG Configuration:1387 - hibernate.c3p0.max_statements=50
07:41:05,043DEBUG Configuration:1387 - hibernate.c3p0.idle_test_period=3000
07:41:05,043DEBUG Configuration:1387 - show_sql=true
07:41:05,043DEBUG Configuration:1387 - format_sql=true
07:41:05,043DEBUG AnnotationConfiguration:596 - null<-org.dom4j.tree.DefaultAttribute@113beb5 [Attribute: name class value "hello.Message"]
07:41:05,053 INFO Configuration:1541 - Configured SessionFactory: null
07:41:05,053DEBUG Configuration:1542 - properties: {hibernate.connection.password=smn-1812, java.runtime.name=Java(TM) 2 Runtime Environment, Standard Edition, sun.boot.library.path=C:\Program Files\Java\jdk1.5.0_11\jre\bin, java.vm.version=1.5.0_11-b03, hibernate.connection.username=snelliga, 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, user.country=US, sun.java.launcher=SUN_STANDARD, sun.os.patch.level=Service Pack 2, java.vm.specification.name=Java Virtual Machine Specification, user.dir=C:\IDEAProjects\JavaPersistenceWithHibernateAnnotations, java.runtime.version=1.5.0_11-b03, java.awt.graphicsenv=sun.awt.Win32GraphicsEnvironment, hibernate.c3p0.max_statements=50, java.endorsed.dirs=C:\Program Files\Java\jdk1.5.0_11\jre\lib\endorsed, os.arch=x86, java.io.tmpdir=C:\DOCUME~1\snelliga\LOCALS~1\Temp\, line.separator=
, java.vm.specification.vendor=Sun Microsystems Inc., user.variant=, os.name=Windows XP, hibernate.c3p0.idle_test_period=3000, sun.jnu.encoding=Cp1252, hibernate.c3p0.timeout=300, java.library.path=C:\Program Files\Java\jdk1.5.0_11\bin;.;C:\WINDOWS\system32;C:\WINDOWS;c:\Program Files\Java\jdk1.5.0_11\bin;c:\oracle\oracle912\bin;C:\Program Files\Oracle\jre\1.3.1\bin;C:\Program Files\Oracle\jre\1.1.8\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\Program Files\Common Files\Autodesk Shared\;C:\ClarifyCRM\eFrontOffice11.5\bin;C:\ClarifyCRM\eFrontOffice11.5\ClearConfigurator\Common Files\CCAutomation;C:\Program Files\Microsoft SQL Server\80\Tools\BINN;C:\Program Files\Synergex\SynergyDE\Workbench\win;C:\Program Files\QuickTime\QTSystem\;C:\WINDOWS\system32\Windows System Resource Manager\bin\;C:\Program Files\Synergex\SynergyDE\connect\;C:\Program Files\Synergex\SynergyDE\dbl\bin\;C:\Program Files\MySQL\MySQL Server 5.0\bin, java.specification.name=Java Platform API Specification, java.class.version=49.0, sun.management.compiler=HotSpot Client Compiler, os.version=5.1, user.home=C:\Documents and Settings\snelliga, user.timezone=America/Chicago, java.awt.printerjob=sun.awt.windows.WPrinterJob, file.encoding=windows-1252, java.specification.version=1.5, hibernate.format_sql=true, hibernate.c3p0.min_size=5, hibernate.connection.driver_class=com.microsoft.jdbc.sqlserver.SQLServerDriver, show_sql=true, user.name=snelliga, java.class.path=C:\Program Files\Java\jdk1.5.0_11\jre\lib\charsets.jar;C:\Program Files\Java\jdk1.5.0_11\jre\lib\deploy.jar;C:\Program Files\Java\jdk1.5.0_11\jre\lib\javaws.jar;C:\Program Files\Java\jdk1.5.0_11\jre\lib\jce.jar;C:\Program Files\Java\jdk1.5.0_11\jre\lib\jsse.jar;C:\Program Files\Java\jdk1.5.0_11\jre\lib\plugin.jar;C:\Program Files\Java\jdk1.5.0_11\jre\lib\rt.jar;C:\Program Files\Java\jdk1.5.0_11\jre\lib\ext\dnsns.jar;C:\Program Files\Java\jdk1.5.0_11\jre\lib\ext\localedata.jar;C:\Program Files\Java\jdk1.5.0_11\jre\lib\ext\sunjce_provider.jar;C:\Program Files\Java\jdk1.5.0_11\jre\lib\ext\sunpkcs11.jar;C:\IDEAProjects\JavaPersistenceWithHibernateAnnotations\classes\production\JavaPersistenceWithHibernateAnnotations;C:\IDEAProjects\JavaPersistenceWithHibernateAnnotations\lib\antlr-2.7.6.jar;C:\IDEAProjects\JavaPersistenceWithHibernateAnnotations\lib\asm-attrs.jar;C:\IDEAProjects\JavaPersistenceWithHibernateAnnotations\lib\asm.jar;C:\IDEAProjects\JavaPersistenceWithHibernateAnnotations\lib\c3p0-0.9.0.jar;C:\IDEAProjects\JavaPersistenceWithHibernateAnnotations\lib\c3p0-0.9.1.jar;C:\IDEAProjects\JavaPersistenceWithHibernateAnnotations\lib\cglib-2.1.3.jar;C:\IDEAProjects\JavaPersistenceWithHibernateAnnotations\lib\commons-collections-2.1.1.jar;C:\IDEAProjects\JavaPersistenceWithHibernateAnnotations\lib\commons-logging-1.0.4.jar;C:\IDEAProjects\JavaPersistenceWithHibernateAnnotations\lib\dom4j-1.6.1.jar;C:\IDEAProjects\JavaPersistenceWithHibernateAnnotations\lib\ejb3-persistence.jar;C:\IDEAProjects\JavaPersistenceWithHibernateAnnotations\lib\hibernate-commons-annotations.jar;C:\IDEAProjects\JavaPersistenceWithHibernateAnnotations\lib\hibernate-tools.jar;C:\IDEAProjects\JavaPersistenceWithHibernateAnnotations\lib\hibernate3.jar;C:\IDEAProjects\JavaPersistenceWithHibernateAnnotations\lib\hsqldb.jar;C:\IDEAProjects\JavaPersistenceWithHibernateAnnotations\lib\j2ee.jar;C:\IDEAProjects\JavaPersistenceWithHibernateAnnotations\lib\jta.jar;C:\IDEAProjects\JavaPersistenceWithHibernateAnnotations\lib\log4j-1.2.11.jar;C:\IDEAProjects\JavaPersistenceWithHibernateAnnotations\lib\log4j-1.2.13.jar;C:\IDEAProjects\JavaPersistenceWithHibernateAnnotations\lib\mssqlserver.jar;C:\IDEAProjects\JavaPersistenceWithHibernateAnnotations\lib\ant-swing-1.6.5.jar;C:\IDEAProjects\JavaPersistenceWithHibernateAnnotations\lib\jboss-jmx.jar;C:\IDEAProjects\JavaPersistenceWithHibernateAnnotations\lib\swarmcache-1.0rc2.jar;C:\IDEAProjects\JavaPersistenceWithHibernateAnnotations\lib\syndiag2.jar;C:\IDEAProjects\JavaPersistenceWithHibernateAnnotations\lib\ant-junit-1.6.5.jar;C:\IDEAProjects\JavaPersistenceWithHibernateAnnotations\lib\checkstyle-all.jar;C:\IDEAProjects\JavaPersistenceWithHibernateAnnotations\lib\jaas.jar;C:\IDEAProjects\JavaPersistenceWithHibernateAnnotations\lib\ant-launcher-1.6.5.jar;C:\IDEAProjects\JavaPersistenceWithHibernateAnnotations\lib\ant-1.6.5.jar;C:\IDEAProjects\JavaPersistenceWithHibernateAnnotations\lib\jboss-common.jar;C:\IDEAProjects\JavaPersistenceWithHibernateAnnotations\lib\javassist.jar;C:\IDEAProjects\JavaPersistenceWithHibernateAnnotations\lib\jgroups-2.2.8.jar;C:\IDEAProjects\JavaPersistenceWithHibernateAnnotations\lib\jboss-cache.jar;C:\IDEAProjects\JavaPersistenceWithHibernateAnnotations\lib\jdbc2_0-stdext.jar;C:\IDEAProjects\JavaPersistenceWithHibernateAnnotations\lib\oscache-2.1.jar;C:\IDEAProjects\JavaPersistenceWithHibernateAnnotations\lib\jboss-system.jar;C:\IDEAProjects\JavaPersistenceWithHibernateAnnotations\lib\versioncheck.jar;C:\IDEAProjects\JavaPersistenceWithHibernateAnnotations\lib\xml-apis.jar;C:\IDEAProjects\JavaPersistenceWithHibernateAnnotations\lib\concurrent-1.3.2.jar;C:\IDEAProjects\JavaPersistenceWithHibernateAnnotations\lib\ehcache-1.2.3.jar;C:\IDEAProjects\JavaPersistenceWithHibernateAnnotations\lib\cleanimports.jar;C:\IDEAProjects\JavaPersistenceWithHibernateAnnotations\lib\jaxen-1.1-beta-7.jar;C:\IDEAProjects\JavaPersistenceWithHibernateAnnotations\lib\junit-3.8.1.jar;C:\IDEAProjects\JavaPersistenceWithHibernateAnnotations\lib\xerces-2.6.2.jar;C:\IDEAProjects\JavaPersistenceWithHibernateAnnotations\lib\connector.jar;C:\IDEAProjects\JavaPersistenceWithHibernateAnnotations\lib\ant-antlr-1.6.5.jar;C:\IDEAProjects\JavaPersistenceWithHibernateAnnotations\lib\jacc-1_0-fr.jar;C:\IDEAProjects\JavaPersistenceWithHibernateAnnotations\lib\proxool-0.8.3.jar;C:\IDEAProjects\JavaPersistenceWithHibernateAnnotations\lib\hibernate-annotations.jar;C:\Program Files\JetBrains\IntelliJ IDEA 7027\lib\idea_rt.jar, format_sql=true, hibernate.bytecode.use_reflection_optimizer=false, hibernate.show_sql=true, java.vm.specification.version=1.0, java.home=C:\Program Files\Java\jdk1.5.0_11\jre, sun.arch.data.model=32, hibernate.dialect=org.hibernate.dialect.SQLServerDialect, hibernate.connection.url=jdbc:microsoft:sqlserver://130.126.4.66:1433;databaseName=StevesTesting;SelectMethod=cursor, user.language=en, java.specification.vendor=Sun Microsystems Inc., hibernate.c3p0.max_size=20, awt.toolkit=sun.awt.windows.WToolkit, java.vm.info=mixed mode, java.version=1.5.0_11, java.ext.dirs=C:\Program Files\Java\jdk1.5.0_11\jre\lib\ext, sun.boot.class.path=C:\Program Files\Java\jdk1.5.0_11\jre\lib\rt.jar;C:\Program Files\Java\jdk1.5.0_11\jre\lib\i18n.jar;C:\Program Files\Java\jdk1.5.0_11\jre\lib\sunrsasign.jar;C:\Program Files\Java\jdk1.5.0_11\jre\lib\jsse.jar;C:\Program Files\Java\jdk1.5.0_11\jre\lib\jce.jar;C:\Program Files\Java\jdk1.5.0_11\jre\lib\charsets.jar;C:\Program Files\Java\jdk1.5.0_11\jre\classes, java.vendor=Sun Microsystems Inc., file.separator=\, java.vendor.url.bug=http://java.sun.com/cgi-bin/bugreport.cgi, sun.io.unicode.encoding=UnicodeLittle, sun.cpu.endian=little, sun.desktop=windows, sun.cpu.isalist=pentium_pro+mmx pentium_pro pentium+mmx pentium i486 i386 i86}
07:41:05,053DEBUG AnnotationConfiguration:758 - Validator not present in classpath, ignoring event listener registration
07:41:05,063DEBUG AnnotationConfiguration:831 - Search not present in classpath, ignoring event listener registration
07:41:05,063DEBUG Configuration:1285 - Preparing to build session factory with filters : {}
07:41:05,063DEBUG AnnotationConfiguration:244 - Execute first pass mapping processing
07:41:05,123DEBUG AnnotationConfiguration:481 - Process hbm files
07:41:05,123DEBUG AnnotationConfiguration:489 - Process annotated classes
07:41:05,123DEBUG AnnotationConfiguration:375 - processing manytoone fk mappings
07:41:05,123DEBUG Configuration:1120 - processing extends queue
07:41:05,123DEBUG Configuration:1124 - processing collection mappings
07:41:05,123DEBUG Configuration:1135 - processing native query and ResultSetMapping mappings
07:41:05,123DEBUG Configuration:1143 - processing association property references
07:41:05,123DEBUG Configuration:1165 - processing foreign key constraints
07:41:05,123 INFO AnnotationConfiguration:350 - Hibernate Validator not found: ignoring
07:41:05,133 INFO C3P0ConnectionProvider:81 - C3P0 using driver: com.microsoft.jdbc.sqlserver.SQLServerDriver at URL: jdbc:microsoft:sqlserver://130.126.4.66:1433;databaseName=StevesTesting;SelectMethod=cursor
07:41:05,133 INFO C3P0ConnectionProvider:82 - Connection properties: {user=snelliga, password=****}
07:41:05,133 INFO C3P0ConnectionProvider:85 - autocommit mode: false
07:41:05,774DEBUG SettingsFactory:347 - could not get database version from JDBC metadata
07:41:05,774 INFO SettingsFactory:89 - RDBMS: Microsoft SQL Server, version: Microsoft SQL Server 2000 - 8.00.760 (Intel X86)
Dec 17 2002 14:22:05
Copyright (c) 1988-2003 Microsoft Corporation
Standard Edition on Windows NT 5.2 (Build 3790: Service Pack 1)

07:41:05,774 INFO SettingsFactory:90 - JDBC driver: SQLServer, version: 2.2.0037
07:41:05,804 INFO Dialect:152 - Using dialect: org.hibernate.dialect.SQLServerDialect
07:41:05,914 INFO TransactionFactoryFactory:31 - Using default transaction strategy (direct JDBC transactions)
07:41:05,924 INFO TransactionManagerLookupFactory:33 - No TransactionManagerLookup configured (in JTA environment, use of read-write or transactional second-level cache is not recommended)
07:41:05,924 INFO SettingsFactory:143 - Automatic flush during beforeCompletion(): disabled
07:41:05,924 INFO SettingsFactory:147 - Automatic session close at end of transaction: disabled
07:41:05,924 INFO SettingsFactory:162 - Scrollable result sets: enabled
07:41:05,924DEBUG SettingsFactory:166 - Wrap result sets: disabled
07:41:05,924 INFO SettingsFactory:170 - JDBC3 getGeneratedKeys(): disabled
07:41:05,924 INFO SettingsFactory:178 - Connection release mode: auto
07:41:05,934 INFO SettingsFactory:205 - Default batch fetch size: 1
07:41:05,934 INFO SettingsFactory:209 - Generate SQL with comments: disabled
07:41:05,934 INFO SettingsFactory:213 - Order SQL updates by primary key: disabled
07:41:05,934 INFO SettingsFactory:217 - Order SQL inserts for batching: disabled
07:41:05,934 INFO SettingsFactory:386 - Query translator: org.hibernate.hql.ast.ASTQueryTranslatorFactory
07:41:05,934 INFO ASTQueryTranslatorFactory:24 - Using ASTQueryTranslatorFactory
07:41:05,934 INFO SettingsFactory:225 - Query language substitutions: {}
07:41:05,934 INFO SettingsFactory:230 - JPA-QL strict compliance: disabled
07:41:05,934 INFO SettingsFactory:235 - Second-level cache: enabled
07:41:05,934 INFO SettingsFactory:239 - Query cache: disabled
07:41:05,934 INFO SettingsFactory:373 - Cache provider: org.hibernate.cache.NoCacheProvider
07:41:05,934 INFO SettingsFactory:254 - Optimize cache for minimal puts: disabled
07:41:05,934 INFO SettingsFactory:263 - Structured second-level cache entries: disabled
07:41:05,944DEBUG SQLExceptionConverterFactory:52 - Using dialect defined converter
07:41:05,954 INFO SettingsFactory:283 - Echoing all SQL to stdout
07:41:05,954 INFO SettingsFactory:290 - Statistics: disabled
07:41:05,954 INFO SettingsFactory:294 - Deleted entity synthetic identifier rollback: disabled
07:41:05,954 INFO SettingsFactory:309 - Default entity-mode: pojo
07:41:05,954 INFO SettingsFactory:313 - Named query checking : enabled
07:41:06,014 INFO SessionFactoryImpl:161 - building session factory
07:41:06,024DEBUG SessionFactoryImpl:173 - Session factory constructed with filter configurations : {}
07:41:06,024DEBUG SessionFactoryImpl:177 - instantiating session factory with properties: {java.runtime.name=Java(TM) 2 Runtime Environment, Standard Edition, hibernate.connection.password=smn-1812, sun.boot.library.path=C:\Program Files\Java\jdk1.5.0_11\jre\bin, java.vm.version=1.5.0_11-b03, hibernate.connection.username=snelliga, 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, user.country=US, sun.java.launcher=SUN_STANDARD, sun.os.patch.level=Service Pack 2, java.vm.specification.name=Java Virtual Machine Specification, user.dir=C:\IDEAProjects\JavaPersistenceWithHibernateAnnotations, java.runtime.version=1.5.0_11-b03, java.awt.graphicsenv=sun.awt.Win32GraphicsEnvironment, java.endorsed.dirs=C:\Program Files\Java\jdk1.5.0_11\jre\lib\endorsed, os.arch=x86, hibernate.c3p0.max_statements=50, java.io.tmpdir=C:\DOCUME~1\snelliga\LOCALS~1\Temp\, line.separator=
, java.vm.specification.vendor=Sun Microsystems Inc., user.variant=, os.name=Windows XP, hibernate.c3p0.idle_test_period=3000, sun.jnu.encoding=Cp1252, hibernate.c3p0.timeout=300, java.library.path=C:\Program Files\Java\jdk1.5.0_11\bin;.;C:\WINDOWS\system32;C:\WINDOWS;c:\Program Files\Java\jdk1.5.0_11\bin;c:\oracle\oracle912\bin;C:\Program Files\Oracle\jre\1.3.1\bin;C:\Program Files\Oracle\jre\1.1.8\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\Program Files\Common Files\Autodesk Shared\;C:\ClarifyCRM\eFrontOffice11.5\bin;C:\ClarifyCRM\eFrontOffice11.5\ClearConfigurator\Common Files\CCAutomation;C:\Program Files\Microsoft SQL Server\80\Tools\BINN;C:\Program Files\Synergex\SynergyDE\Workbench\win;C:\Program Files\QuickTime\QTSystem\;C:\WINDOWS\system32\Windows System Resource Manager\bin\;C:\Program Files\Synergex\SynergyDE\connect\;C:\Program Files\Synergex\SynergyDE\dbl\bin\;C:\Program Files\MySQL\MySQL Server 5.0\bin, java.specification.name=Java Platform API Specification, java.class.version=49.0, sun.management.compiler=HotSpot Client Compiler, os.version=5.1, user.home=C:\Documents and Settings\snelliga, user.timezone=America/Chicago, java.awt.printerjob=sun.awt.windows.WPrinterJob, java.specification.version=1.5, file.encoding=windows-1252, hibernate.format_sql=true, hibernate.c3p0.min_size=5, hibernate.connection.driver_class=com.microsoft.jdbc.sqlserver.SQLServerDriver, show_sql=true, java.class.path=C:\Program Files\Java\jdk1.5.0_11\jre\lib\charsets.jar;C:\Program Files\Java\jdk1.5.0_11\jre\lib\deploy.jar;C:\Program Files\Java\jdk1.5.0_11\jre\lib\javaws.jar;C:\Program Files\Java\jdk1.5.0_11\jre\lib\jce.jar;C:\Program Files\Java\jdk1.5.0_11\jre\lib\jsse.jar;C:\Program Files\Java\jdk1.5.0_11\jre\lib\plugin.jar;C:\Program Files\Java\jdk1.5.0_11\jre\lib\rt.jar;C:\Program Files\Java\jdk1.5.0_11\jre\lib\ext\dnsns.jar;C:\Program Files\Java\jdk1.5.0_11\jre\lib\ext\localedata.jar;C:\Program Files\Java\jdk1.5.0_11\jre\lib\ext\sunjce_provider.jar;C:\Program Files\Java\jdk1.5.0_11\jre\lib\ext\sunpkcs11.jar;C:\IDEAProjects\JavaPersistenceWithHibernateAnnotations\classes\production\JavaPersistenceWithHibernateAnnotations;C:\IDEAProjects\JavaPersistenceWithHibernateAnnotations\lib\antlr-2.7.6.jar;C:\IDEAProjects\JavaPersistenceWithHibernateAnnotations\lib\asm-attrs.jar;C:\IDEAProjects\JavaPersistenceWithHibernateAnnotations\lib\asm.jar;C:\IDEAProjects\JavaPersistenceWithHibernateAnnotations\lib\c3p0-0.9.0.jar;C:\IDEAProjects\JavaPersistenceWithHibernateAnnotations\lib\c3p0-0.9.1.jar;C:\IDEAProjects\JavaPersistenceWithHibernateAnnotations\lib\cglib-2.1.3.jar;C:\IDEAProjects\JavaPersistenceWithHibernateAnnotations\lib\commons-collections-2.1.1.jar;C:\IDEAProjects\JavaPersistenceWithHibernateAnnotations\lib\commons-logging-1.0.4.jar;C:\IDEAProjects\JavaPersistenceWithHibernateAnnotations\lib\dom4j-1.6.1.jar;C:\IDEAProjects\JavaPersistenceWithHibernateAnnotations\lib\ejb3-persistence.jar;C:\IDEAProjects\JavaPersistenceWithHibernateAnnotations\lib\hibernate-commons-annotations.jar;C:\IDEAProjects\JavaPersistenceWithHibernateAnnotations\lib\hibernate-tools.jar;C:\IDEAProjects\JavaPersistenceWithHibernateAnnotations\lib\hibernate3.jar;C:\IDEAProjects\JavaPersistenceWithHibernateAnnotations\lib\hsqldb.jar;C:\IDEAProjects\JavaPersistenceWithHibernateAnnotations\lib\j2ee.jar;C:\IDEAProjects\JavaPersistenceWithHibernateAnnotations\lib\jta.jar;C:\IDEAProjects\JavaPersistenceWithHibernateAnnotations\lib\log4j-1.2.11.jar;C:\IDEAProjects\JavaPersistenceWithHibernateAnnotations\lib\log4j-1.2.13.jar;C:\IDEAProjects\JavaPersistenceWithHibernateAnnotations\lib\mssqlserver.jar;C:\IDEAProjects\JavaPersistenceWithHibernateAnnotations\lib\ant-swing-1.6.5.jar;C:\IDEAProjects\JavaPersistenceWithHibernateAnnotations\lib\jboss-jmx.jar;C:\IDEAProjects\JavaPersistenceWithHibernateAnnotations\lib\swarmcache-1.0rc2.jar;C:\IDEAProjects\JavaPersistenceWithHibernateAnnotations\lib\syndiag2.jar;C:\IDEAProjects\JavaPersistenceWithHibernateAnnotations\lib\ant-junit-1.6.5.jar;C:\IDEAProjects\JavaPersistenceWithHibernateAnnotations\lib\checkstyle-all.jar;C:\IDEAProjects\JavaPersistenceWithHibernateAnnotations\lib\jaas.jar;C:\IDEAProjects\JavaPersistenceWithHibernateAnnotations\lib\ant-launcher-1.6.5.jar;C:\IDEAProjects\JavaPersistenceWithHibernateAnnotations\lib\ant-1.6.5.jar;C:\IDEAProjects\JavaPersistenceWithHibernateAnnotations\lib\jboss-common.jar;C:\IDEAProjects\JavaPersistenceWithHibernateAnnotations\lib\javassist.jar;C:\IDEAProjects\JavaPersistenceWithHibernateAnnotations\lib\jgroups-2.2.8.jar;C:\IDEAProjects\JavaPersistenceWithHibernateAnnotations\lib\jboss-cache.jar;C:\IDEAProjects\JavaPersistenceWithHibernateAnnotations\lib\jdbc2_0-stdext.jar;C:\IDEAProjects\JavaPersistenceWithHibernateAnnotations\lib\oscache-2.1.jar;C:\IDEAProjects\JavaPersistenceWithHibernateAnnotations\lib\jboss-system.jar;C:\IDEAProjects\JavaPersistenceWithHibernateAnnotations\lib\versioncheck.jar;C:\IDEAProjects\JavaPersistenceWithHibernateAnnotations\lib\xml-apis.jar;C:\IDEAProjects\JavaPersistenceWithHibernateAnnotations\lib\concurrent-1.3.2.jar;C:\IDEAProjects\JavaPersistenceWithHibernateAnnotations\lib\ehcache-1.2.3.jar;C:\IDEAProjects\JavaPersistenceWithHibernateAnnotations\lib\cleanimports.jar;C:\IDEAProjects\JavaPersistenceWithHibernateAnnotations\lib\jaxen-1.1-beta-7.jar;C:\IDEAProjects\JavaPersistenceWithHibernateAnnotations\lib\junit-3.8.1.jar;C:\IDEAProjects\JavaPersistenceWithHibernateAnnotations\lib\xerces-2.6.2.jar;C:\IDEAProjects\JavaPersistenceWithHibernateAnnotations\lib\connector.jar;C:\IDEAProjects\JavaPersistenceWithHibernateAnnotations\lib\ant-antlr-1.6.5.jar;C:\IDEAProjects\JavaPersistenceWithHibernateAnnotations\lib\jacc-1_0-fr.jar;C:\IDEAProjects\JavaPersistenceWithHibernateAnnotations\lib\proxool-0.8.3.jar;C:\IDEAProjects\JavaPersistenceWithHibernateAnnotations\lib\hibernate-annotations.jar;C:\Program Files\JetBrains\IntelliJ IDEA 7027\lib\idea_rt.jar, user.name=snelliga, hibernate.bytecode.use_reflection_optimizer=false, format_sql=true, hibernate.show_sql=true, java.vm.specification.version=1.0, sun.arch.data.model=32, java.home=C:\Program Files\Java\jdk1.5.0_11\jre, hibernate.connection.url=jdbc:microsoft:sqlserver://130.126.4.66:1433;databaseName=StevesTesting;SelectMethod=cursor, hibernate.dialect=org.hibernate.dialect.SQLServerDialect, java.specification.vendor=Sun Microsystems Inc., user.language=en, awt.toolkit=sun.awt.windows.WToolkit, hibernate.c3p0.max_size=20, java.vm.info=mixed mode, java.version=1.5.0_11, java.ext.dirs=C:\Program Files\Java\jdk1.5.0_11\jre\lib\ext, sun.boot.class.path=C:\Program Files\Java\jdk1.5.0_11\jre\lib\rt.jar;C:\Program Files\Java\jdk1.5.0_11\jre\lib\i18n.jar;C:\Program Files\Java\jdk1.5.0_11\jre\lib\sunrsasign.jar;C:\Program Files\Java\jdk1.5.0_11\jre\lib\jsse.jar;C:\Program Files\Java\jdk1.5.0_11\jre\lib\jce.jar;C:\Program Files\Java\jdk1.5.0_11\jre\lib\charsets.jar;C:\Program Files\Java\jdk1.5.0_11\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, sun.desktop=windows, sun.cpu.isalist=pentium_pro+mmx pentium_pro pentium+mmx pentium i486 i386 i86}
07:41:06,034DEBUG SessionFactoryObjectFactory:39 - initializing class SessionFactoryObjectFactory
07:41:06,034DEBUG SessionFactoryObjectFactory:76 - registered: 02fe864b13680ca60113680ca6e80000 (unnamed)
07:41:06,034 INFO SessionFactoryObjectFactory:82 - Not binding factory to JNDI, no JNDI name configured
07:41:06,034DEBUG SessionFactoryImpl:308 - instantiated session factory
07:41:06,034DEBUG SessionFactoryImpl:392 - Checking 0 named HQL queries
07:41:06,034DEBUG SessionFactoryImpl:412 - Checking 0 named SQL queries
07:41:06,134DEBUG SessionImpl:220 - opened session at timestamp: 11828616660
07:41:06,134DEBUG JDBCTransaction:54 - begin
07:41:06,134DEBUG ConnectionManager:421 - opening JDBC connection
07:41:06,144DEBUG JDBCTransaction:59 - current autocommit status: false
07:41:06,144DEBUG JDBCContext:210 - after transaction begin
07:41:12,103DEBUG DefaultSaveOrUpdateEventListener:158 - saving transient instance

_________________
Steve


Top
 Profile  
 
 Post subject: I am having the same problem, but connecting to hsqldb
PostPosted: Wed Feb 13, 2008 2:39 pm 
Newbie

Joined: Wed Feb 13, 2008 2:32 pm
Posts: 2
I am running the example from Java Persistence with Hibernate, up to and including section 2.2.1 (page 72). The previous example app worked fine, then I modified it using Hibernate Annotations, and receive the error below (SessionFactoryObjectFactory:82 - Not binding factory to JNDI, no JNDI name configured). Any help would be appreciated. Thank you, Anthony.



D:\Anthony\helloworld>ant run
Buildfile: build.xml
[echo] D:\Anthony\helloworld\lib\ant-1.6.5.jar;D:\Anthony\helloworld\lib\ant-antlr-1.6.5.jar;D:\Anthony\helloworld\lib\a
nt-junit-1.6.5.jar;D:\Anthony\helloworld\lib\ant-launcher-1.6.5.jar;D:\Anthony\helloworld\lib\ant-swing-1.6.5.jar;D:\Anthony\
helloworld\lib\antlr-2.7.6.jar;D:\Anthony\helloworld\lib\asm-attrs.jar;D:\Anthony\helloworld\lib\asm.jar;D:\Anthony\helloworl
d\lib\c3p0-0.9.1.jar;D:\Anthony\helloworld\lib\cglib-2.1.3.jar;D:\Anthony\helloworld\lib\checkstyle-all.jar;D:\Anthony\hellow
orld\lib\cleanimports.jar;D:\Anthony\helloworld\lib\commons-collections-2.1.1.jar;D:\Anthony\helloworld\lib\commons-logging-1
.0.4.jar;D:\Anthony\helloworld\lib\concurrent-1.3.2.jar;D:\Anthony\helloworld\lib\connector.jar;D:\Anthony\helloworld\lib\dom
4j-1.6.1.jar;D:\Anthony\helloworld\lib\ehcache-1.2.3.jar;D:\Anthony\helloworld\lib\ejb3-persistence.jar;D:\Anthony\helloworld
\lib\hibernate-annotations.jar;D:\Anthony\helloworld\lib\hibernate-commons-annotations.jar;D:\Anthony\helloworld\lib\hibernat
e-entitymanager.jar;D:\Anthony\helloworld\lib\hibernate-tools.jar;D:\Anthony\helloworld\lib\hibernate3.jar;D:\Anthony\hellowo
rld\lib\hsqldb.jar;D:\Anthony\helloworld\lib\jaas.jar;D:\Anthony\helloworld\lib\jacc-1_0-fr.jar;D:\Anthony\helloworld\lib\jav
assist.jar;D:\Anthony\helloworld\lib\jaxen-1.1-beta-7.jar;D:\Anthony\helloworld\lib\jboss-cache.jar;D:\Anthony\helloworld\lib
\jboss-common.jar;D:\Anthony\helloworld\lib\jboss-jmx.jar;D:\Anthony\helloworld\lib\jboss-system.jar;D:\Anthony\helloworld\li
b\jdbc2_0-stdext.jar;D:\Anthony\helloworld\lib\jgroups-2.2.8.jar;D:\Anthony\helloworld\lib\jta.jar;D:\Anthony\helloworld\lib\
junit-3.8.1.jar;D:\Anthony\helloworld\lib\log4j-1.2.11.jar;D:\Anthony\helloworld\lib\oscache-2.1.jar;D:\Anthony\helloworld\li
b\proxool-0.8.3.jar;D:\Anthony\helloworld\lib\swarmcache-1.0rc2.jar;D:\Anthony\helloworld\lib\syndiag2.jar;D:\Anthony\hellowo
rld\lib\versioncheck.jar;D:\Anthony\helloworld\lib\xerces-2.6.2.jar;D:\Anthony\helloworld\lib\xml-apis.jar

clean:
[delete] Deleting directory D:\Anthony\helloworld\bin
[mkdir] Created dir: D:\Anthony\helloworld\bin

compile:
[javac] Compiling 3 source files to D:\Anthony\helloworld\bin

copymetafiles:
[copy] Copying 2 files to D:\Anthony\helloworld\bin

run:
[java] 13:37:45,311 INFO Version:15 - Hibernate Annotations 3.3.0.GA
[java] 13:37:45,343 INFO Environment:514 - Hibernate 3.2.5
[java] 13:37:45,343 INFO Environment:547 - hibernate.properties not found
[java] 13:37:45,343 INFO Environment:681 - Bytecode provider name : cglib
[java] 13:37:45,358 INFO Environment:598 - using JDK 1.4 java.sql.Timestamp handling
[java] 13:37:45,452 INFO Configuration:1426 - configuring from resource: hibernate.cfg.xml
[java] 13:37:45,452 INFO Configuration:1403 - Configuration resource: hibernate.cfg.xml
[java] 13:37:45,780 INFO Configuration:1541 - Configured SessionFactory: null
[java] 13:37:45,889 INFO AnnotationBinder:398 - Binding entity from annotated class: hello.Message
[java] 13:37:45,936 INFO EntityBinder:420 - Bind entity hello.Message on table MESSAGES
[java] 13:37:46,170 INFO AnnotationConfiguration:350 - Hibernate Validator not found: ignoring
[java] 13:37:46,185 INFO C3P0ConnectionProvider:81 - C3P0 using driver: org.hsqldb.jdbcDriver at URL: jdbc:hsqldb:hsql:
//localhost
[java] 13:37:46,185 INFO C3P0ConnectionProvider:82 - Connection properties: {user=sa}
[java] 13:37:46,185 INFO C3P0ConnectionProvider:85 - autocommit mode: false
[java] 13:37:46,217 INFO MLog:80 - MLog clients using log4j logging.
[java] 13:37:46,466 INFO C3P0Registry:204 - Initializing c3p0-0.9.1 [built 16-January-2007 14:46:42; debug? true; trace
: 10]
[java] 13:37:46,575 INFO AbstractPoolBackedDataSource:462 - Initializing c3p0 pool... com.mchange.v2.c3p0.PoolBackedDat
aSource@f6cbcf5c [ connectionPoolDataSource -> com.mchange.v2.c3p0.WrapperConnectionPoolDataSource@fa02a5ef [ acquireIncremen
t -> 3, acquireRetryAttempts -> 30, acquireRetryDelay -> 1000, autoCommitOnClose -> false, automaticTestTable -> null, breakA
fterAcquireFailure -> false, checkoutTimeout -> 0, connectionCustomizerClassName -> null, connectionTesterClassName -> com.mc
hange.v2.c3p0.impl.DefaultConnectionTester, debugUnreturnedConnectionStackTraces -> false, factoryClassLocation -> null, forc
eIgnoreUnresolvedTransactions -> false, identityToken -> 2rvyoq7s5knkxjvv3g8c|b7b3f9, idleConnectionTestPeriod -> 3000, initi
alPoolSize -> 5, maxAdministrativeTaskTime -> 0, maxConnectionAge -> 0, maxIdleTime -> 300, maxIdleTimeExcessConnections -> 0
, maxPoolSize -> 20, maxStatements -> 50, maxStatementsPerConnection -> 0, minPoolSize -> 5, nestedDataSource -> com.mchange.
v2.c3p0.DriverManagerDataSource@f871b70f [ description -> null, driverClass -> null, factoryClassLocation -> null, identityTo
ken -> 2rvyoq7s5knkxjvv3g8c|c623af, jdbcUrl -> jdbc:hsqldb:hsql://localhost, properties -> {user=******} ], preferredTestQuer
y -> null, propertyCycle -> 0, testConnectionOnCheckin -> false, testConnectionOnCheckout -> false, unreturnedConnectionTimeo
ut -> 0, usesTraditionalReflectiveProxies -> false; userOverrides: {} ], dataSourceName -> null, factoryClassLocation -> null
, identityToken -> 2rvyoq7s5knkxjvv3g8c|d507e9, numHelperThreads -> 3 ]
[java] 13:37:46,794 INFO SettingsFactory:89 - RDBMS: HSQL Database Engine, version: 1.8.0
[java] 13:37:46,794 INFO SettingsFactory:90 - JDBC driver: HSQL Database Engine Driver, version: 1.8.0
[java] 13:37:46,810 INFO Dialect:152 - Using dialect: org.hibernate.dialect.HSQLDialect
[java] 13:37:46,825 INFO TransactionFactoryFactory:31 - Using default transaction strategy (direct JDBC transactions)
[java] 13:37:46,841 INFO TransactionManagerLookupFactory:33 - No TransactionManagerLookup configured (in JTA environmen
t, use of read-write or transactional second-level cache is not recommended)
[java] 13:37:46,841 INFO SettingsFactory:143 - Automatic flush during beforeCompletion(): disabled
[java] 13:37:46,841 INFO SettingsFactory:147 - Automatic session close at end of transaction: disabled
[java] 13:37:46,841 INFO SettingsFactory:154 - JDBC batch size: 15
[java] 13:37:46,841 INFO SettingsFactory:157 - JDBC batch updates for versioned data: disabled
[java] 13:37:46,841 INFO SettingsFactory:162 - Scrollable result sets: enabled
[java] 13:37:46,841 INFO SettingsFactory:170 - JDBC3 getGeneratedKeys(): disabled
[java] 13:37:46,841 INFO SettingsFactory:178 - Connection release mode: auto
[java] 13:37:46,841 INFO SettingsFactory:205 - Default batch fetch size: 1
[java] 13:37:46,841 INFO SettingsFactory:209 - Generate SQL with comments: enabled
[java] 13:37:46,841 INFO SettingsFactory:213 - Order SQL updates by primary key: disabled
[java] 13:37:46,841 INFO SettingsFactory:217 - Order SQL inserts for batching: disabled
[java] 13:37:46,841 INFO SettingsFactory:386 - Query translator: org.hibernate.hql.ast.ASTQueryTranslatorFactory
[java] 13:37:46,856 INFO ASTQueryTranslatorFactory:24 - Using ASTQueryTranslatorFactory
[java] 13:37:46,856 INFO SettingsFactory:225 - Query language substitutions: {}
[java] 13:37:46,856 INFO SettingsFactory:230 - JPA-QL strict compliance: disabled
[java] 13:37:46,856 INFO SettingsFactory:235 - Second-level cache: enabled
[java] 13:37:46,856 INFO SettingsFactory:239 - Query cache: disabled
[java] 13:37:46,856 INFO SettingsFactory:373 - Cache provider: org.hibernate.cache.NoCacheProvider
[java] 13:37:46,856 INFO SettingsFactory:254 - Optimize cache for minimal puts: disabled
[java] 13:37:46,856 INFO SettingsFactory:263 - Structured second-level cache entries: disabled
[java] 13:37:46,856 INFO SettingsFactory:283 - Echoing all SQL to stdout
[java] 13:37:46,856 INFO SettingsFactory:290 - Statistics: disabled
[java] 13:37:46,856 INFO SettingsFactory:294 - Deleted entity synthetic identifier rollback: disabled
[java] 13:37:46,872 INFO SettingsFactory:309 - Default entity-mode: pojo
[java] 13:37:46,872 INFO SettingsFactory:313 - Named query checking : enabled
[java] 13:37:46,903 INFO SessionFactoryImpl:161 - building session factory
[java] 13:37:47,215 INFO SessionFactoryObjectFactory:82 - Not binding factory to JNDI, no JNDI name configured
[java] Hibernate:
[java] /* insert hello.Message
[java] */ insert
[java] into
[java] MESSAGES
[java] (MESSAGE_ID, NEXT_MESSAGE_ID, MESSAGE_TEXT)
[java] values
[java] (null, ?, ?)
[java] 13:37:47,356 WARN JDBCExceptionReporter:77 - SQL Error: -10, SQLState: 23000
[java] 13:37:47,356 ERROR JDBCExceptionReporter:78 - Attempt to insert null into a non-nullable column: column: MESSAGE_
ID table: MESSAGES in statement [/* insert hello.Message */ insert into MESSAGES (MESSAGE_ID, NEXT_MESSAGE_ID, MESSAGE_TEXT)
values (null, ?, ?)]
[java] Exception in thread "main" org.hibernate.exception.ConstraintViolationException: could not insert: [hello.Message
]
[java] at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:71)
[java] at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
[java] at org.hibernate.id.insert.AbstractSelectingDelegate.performInsert(AbstractSelectingDelegate.java:40)
[java] at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2158)
[java] at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2638)
[java] at org.hibernate.action.EntityIdentityInsertAction.execute(EntityIdentityInsertAction.java:48)
[java] at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:250)
[java] at org.hibernate.event.def.AbstractSaveEventListener.performSaveOrReplicate(AbstractSaveEventListener.java:29
8)
[java] at org.hibernate.event.def.AbstractSaveEventListener.performSave(AbstractSaveEventListener.java:181)
[java] at org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:107)
[java] at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdat
eEventListener.java:187)
[java] at org.hibernate.event.def.DefaultSaveEventListener.saveWithGeneratedOrRequestedId(DefaultSaveEventListener.j
ava:33)
[java] at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListene
r.java:172)
[java] at org.hibernate.event.def.DefaultSaveEventListener.performSaveOrUpdate(DefaultSaveEventListener.java:27)
[java] at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.j
ava:70)
[java] at org.hibernate.impl.SessionImpl.fireSave(SessionImpl.java:535)
[java] at org.hibernate.impl.SessionImpl.save(SessionImpl.java:523)
[java] at org.hibernate.impl.SessionImpl.save(SessionImpl.java:519)
[java] at hello.HelloWorld.main(Unknown Source)
[java] Caused by: java.sql.SQLException: Attempt to insert null into a non-nullable column: column: MESSAGE_ID table: ME
SSAGES in statement [/* insert hello.Message */ insert into MESSAGES (MESSAGE_ID, NEXT_MESSAGE_ID, MESSAGE_TEXT) values (null
, ?, ?)]
[java] at org.hsqldb.jdbc.Util.throwError(Unknown Source)
[java] at org.hsqldb.jdbc.jdbcPreparedStatement.executeUpdate(Unknown Source)
[java] at com.mchange.v2.c3p0.impl.NewProxyPreparedStatement.executeUpdate(NewProxyPreparedStatement.java:105)
[java] at org.hibernate.id.insert.AbstractSelectingDelegate.performInsert(AbstractSelectingDelegate.java:33)
[java] ... 16 more


[java] Java Result: 1

BUILD SUCCESSFUL
Total time: 4 seconds
D:\Anthony\helloworld>


Top
 Profile  
 
 Post subject: reply to : aalcamo
PostPosted: Fri Feb 15, 2008 7:48 am 
Beginner
Beginner

Joined: Fri Oct 06, 2006 7:11 am
Posts: 32
Looks like your trying to insert a null into a non nullable field.

You need to look at what generator you're using to generate your MESSAGE_IDin your Message.hbm.xml file... or your annotations if your using those...

e.g (not using annotations)


Code:

<hibernate-mapping>
    <class name="hello.Message" table="MESSAGE">
       <id name="messageId" column="MESSAGE_ID" type="long" unsaved-value="0">
           <generator class="sequence">
              <param name="sequence">MESSAGE_ID_SEQ</param>
           </generator>
       </id>
      <property name="messageText" column="MESSAGE_TEXT"/>
</hibernate-mapping>



Hope this helps ... please rate !!


Top
 Profile  
 
 Post subject:
PostPosted: Wed Feb 27, 2008 8:07 pm 
Newbie

Joined: Wed Feb 27, 2008 7:51 pm
Posts: 1
if you're using ant to generate your DB schema (with the hibernatetools task), the helloworld-dll.sql generated by both <configuration> and <annotationconfiguration> are different (of course, if you were following the book instructions, your cfg.xml has the annotated class tag in place of the mapping xml).

try to re-generate your schema using <annotationconfiguration> and your problem may be solved.

and don't forget to use the AnnotationConfiguration class instead of Configuration (on your HibernateUtil class).

sessionFactory = new AnnotationConfiguration().configure().buildSessionFactory();


cya


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 28, 2008 10:04 am 
Newbie

Joined: Wed Jan 23, 2008 6:15 am
Posts: 6
Answer to snelliga original question:
You must have @Entity class-level annotation for Message class in order to make it valid Hibernate mapped entity/


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 21, 2008 5:31 am 
Newbie

Joined: Fri Mar 21, 2008 4:09 am
Posts: 6
Location: Kyiv, Ukraine
To aalcamo.
As has said rogoo You should delete old DB(files test.lck, test.log, test.properties in your workdir), and then generate a new(ant schemaexport).


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