-->
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: how to update a record with component mapping
PostPosted: Thu Dec 28, 2006 2:42 am 
Newbie

Joined: Thu Dec 28, 2006 2:09 am
Posts: 1
Hibernate version: 3.0

Mapping documents: Person.hbm.xml

<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd" >

<hibernate-mapping>
<class name="com.yash.hibernate.Person" table="person_Y">
<id name="id" column="pid" type="int">
<generator class="increment" />
</id>
<property name="birthday" type="date" />
<component name="Name" class="com.yash.hibernate.Name"><!-- class attribute optional -->
<!--
<parent name="namedPerson"/> --><!-- reference back to the Person -->
<property name="initial" />
<property name="first" />
<property name="last" />
</component>
<set name="personQualifications" table="PersonQualifications_Y" lazy="true" cascade="save-update">
<key column="id" not-null="true"></key>
<composite-element class="com.yash.hibernate.PersonQualification"><!-- class attribute required -->
<property name="collegeStudied" />
<property name="qualification" />
</composite-element>
</set>
<set name="emailAddresses" table="PersonEmailAddresses_Y">
<key column="id" not-null="true" />
<element type="string" column="EMAIL_ADDRESS" />
</set>
</class>
</hibernate-mapping>


Code between sessionFactory.openSession() and session.close():
session =sessionFactory.openSession();
Person person=(Person)session.load(Person.class,new Integer(1));
//Iterator itr=
person.getPersonQualifications().add(new PersonQualification("asd", "asd"));
session.save(person);
session.flush();
session.close();


Full stack trace of any exception that occurs: No exceptions

Name and version of the database you are using: Microsoft SQL server

The generated SQL (show_sql=true):

Debug level Hibernate log excerpt:

12:05:58,236 INFO Environment:456 - Hibernate 3.0rc1
12:05:58,251 INFO Environment:469 - hibernate.properties not found
12:05:58,251 INFO Environment:502 - using CGLIB reflection optimizer
12:05:58,251 INFO Environment:532 - using JDK 1.4 java.sql.Timestamp handling
12:05:58,251 INFO Configuration:1228 - configuring from resource: /hibernate.cfg.xml
12:05:58,251 INFO Configuration:1199 - Configuration resource: /hibernate.cfg.xml
12:05:58,548 DEBUG DTDEntityResolver:42 - trying to locate http://hibernate.sourceforge.net/hibern ... on-3.0.dtd in classpath under org/hibernate/
12:05:58,548 DEBUG DTDEntityResolver:53 - found http://hibernate.sourceforge.net/hibern ... on-3.0.dtd in classpath
12:05:58,611 DEBUG Configuration:1185 - hibernate.connection.driver_class=com.microsoft.jdbc.sqlserver.SQLServerDriver
12:05:58,611 DEBUG Configuration:1185 - hibernate.connection.url=jdbc:microsoft:sqlserver://10.7.100.146:1433;databasename=YashTraining
12:05:58,611 DEBUG Configuration:1185 - hibernate.connection.username=trainingyash
12:05:58,611 DEBUG Configuration:1185 - hibernate.connection.password=trainingyash
12:05:58,611 DEBUG Configuration:1185 - hibernate.connection.pool_size=10
12:05:58,611 DEBUG Configuration:1185 - show_sql=true
12:05:58,611 DEBUG Configuration:1185 - hibernate.hbm2ddl.auto=update
12:05:58,611 DEBUG Configuration:1185 - dialect=org.hibernate.dialect.SQLServerDialect
12:05:58,611 DEBUG Configuration:1380 - null<-org.dom4j.tree.DefaultAttribute@4c1103 [Attribute: name resource value "com/yash/hibernate/Person.hbm.xml"]
12:05:58,611 INFO Configuration:439 - Mapping resource: com/yash/hibernate/Person.hbm.xml
12:05:58,626 DEBUG DTDEntityResolver:42 - trying to locate http://hibernate.sourceforge.net/hibern ... ng-3.0.dtd in classpath under org/hibernate/
12:05:58,626 DEBUG DTDEntityResolver:53 - found http://hibernate.sourceforge.net/hibern ... ng-3.0.dtd in classpath
12:05:58,767 INFO HbmBinder:256 - Mapping class: com.yash.hibernate.Person -> person_Y
12:05:58,782 DEBUG HbmBinder:1086 - Mapped property: id -> pid
12:05:58,798 DEBUG HbmBinder:1086 - Mapped property: birthday -> birthday
12:05:58,814 DEBUG HbmBinder:1086 - Mapped property: initial -> initial
12:05:58,814 DEBUG HbmBinder:1086 - Mapped property: first -> first
12:05:58,814 DEBUG HbmBinder:1086 - Mapped property: last -> last
12:05:58,814 DEBUG HbmBinder:1086 - Mapped property: Name -> initial, first, last
12:05:58,814 INFO HbmBinder:1194 - Mapping collection: com.yash.hibernate.Person.personQualifications -> PersonQualifications_Y
12:05:58,814 DEBUG HbmBinder:1086 - Mapped property: personQualifications
12:05:58,814 INFO HbmBinder:1194 - Mapping collection: com.yash.hibernate.Person.emailAddresses -> PersonEmailAddresses_Y
12:05:58,814 DEBUG HbmBinder:1086 - Mapped property: emailAddresses
12:05:58,814 INFO Configuration:1340 - Configured SessionFactory: null
12:05:58,814 DEBUG Configuration:1341 - properties: {hibernate.connection.password=trainingyash, java.runtime.name=Java(TM) 2 Runtime Environment, Standard Edition, sun.boot.library.path=C:\j2sdk1.4.0_02\jre\bin, java.vm.version=1.4.0_02-b02, hibernate.connection.username=trainingyash, 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.os.patch.level=Service Pack 4, java.vm.specification.name=Java Virtual Machine Specification, user.dir=D:\ServletHibernate\ComponentTest, java.runtime.version=1.4.0_02-b02, java.awt.graphicsenv=sun.awt.Win32GraphicsEnvironment, java.endorsed.dirs=C:\j2sdk1.4.0_02\jre\lib\endorsed, os.arch=x86, java.io.tmpdir=C:\DOCUME~1\vandanat\LOCALS~1\Temp\, line.separator=
, java.vm.specification.vendor=Sun Microsystems Inc., user.variant=, os.name=Windows 2000, sun.java2d.fontpath=, java.library.path=C:\j2sdk1.4.0_02\bin;.;C:\WINNT\system32;C:\WINNT;C:\Program Files\IBM\WebSphere Studio\Application Developer\v5.1.1\eclipse\jre\bin;C:\WINNT\system32;C:\WINNT;C:\WINNT\System32\Wbem;C:\PROGRA~1\IBM\IMNNQ;C:\Program Files\SQLLIB\BIN;C:\Program Files\SQLLIB\FUNCTION;C:\Program Files\SQLLIB\SAMPLES\REPL;C:\Program Files\SQLLIB\HELP;C:\Program Files\Microsoft SQL Server\80\Tools\BINN, java.specification.name=Java Platform API Specification, java.class.version=48.0, hibernate.connection.pool_size=10, java.util.prefs.PreferencesFactory=java.util.prefs.WindowsPreferencesFactory, os.version=5.0, user.home=C:\Documents and Settings\vandanat, user.timezone=GMT+05:30, java.awt.printerjob=sun.awt.windows.WPrinterJob, file.encoding=Cp1252, java.specification.version=1.4, hibernate.connection.driver_class=com.microsoft.jdbc.sqlserver.SQLServerDriver, show_sql=true, user.name=vandanat, java.class.path=D:\ServletHibernate\ComponentTest\classes;D:\ServletHibernate\ComponentTest\lib\antlr-2.7.6.jar;D:\ServletHibernate\ComponentTest\lib\asm.jar;D:\ServletHibernate\ComponentTest\lib\asm-attrs.jar;D:\ServletHibernate\ComponentTest\lib\cglib-2.1.3.jar;D:\ServletHibernate\ComponentTest\lib\cglib-nodep-2.1_2.jar;D:\ServletHibernate\ComponentTest\lib\commons-collections-2.1.1.jar;D:\ServletHibernate\ComponentTest\lib\commons-logging-1.0.4.jar;D:\ServletHibernate\ComponentTest\lib\dom4j-1.5.2.jar;D:\ServletHibernate\ComponentTest\lib\ehcache-1.1.jar;D:\ServletHibernate\ComponentTest\lib\hibernate3.jar;D:\ServletHibernate\ComponentTest\lib\jdbc2_0-stdext.jar;D:\ServletHibernate\ComponentTest\lib\jta.jar;D:\ServletHibernate\ComponentTest\lib\log4j-1.2.9.jar;D:\ServletHibernate\ComponentTest\lib\msbase.jar;D:\ServletHibernate\ComponentTest\lib\mssqlserver.jar;D:\ServletHibernate\ComponentTest\lib\msutil.jar;D:\ServletHibernate\ComponentTest\lib\xerces-2.6.2.jar;D:\ServletHibernate\ComponentTest\lib\xml-apis.jar, hibernate.show_sql=true, java.vm.specification.version=1.0, java.home=C:\j2sdk1.4.0_02\jre, sun.arch.data.model=32, hibernate.dialect=org.hibernate.dialect.SQLServerDialect, hibernate.connection.url=jdbc:microsoft:sqlserver://10.7.100.146:1433;databasename=YashTraining, user.language=en, java.specification.vendor=Sun Microsystems Inc., awt.toolkit=sun.awt.windows.WToolkit, hibernate.cglib.use_reflection_optimizer=true, java.vm.info=mixed mode, java.version=1.4.0_02, java.ext.dirs=C:\j2sdk1.4.0_02\jre\lib\ext, sun.boot.class.path=C:\j2sdk1.4.0_02\jre\lib\rt.jar;C:\j2sdk1.4.0_02\jre\lib\i18n.jar;C:\j2sdk1.4.0_02\jre\lib\sunrsasign.jar;C:\j2sdk1.4.0_02\jre\lib\jsse.jar;C:\j2sdk1.4.0_02\jre\lib\jce.jar;C:\j2sdk1.4.0_02\jre\lib\charsets.jar;C:\j2sdk1.4.0_02\jre\classes, java.vendor=Sun Microsystems Inc., file.separator=\, hibernate.hbm2ddl.auto=update, java.vendor.url.bug=http://java.sun.com/cgi-bin/bugreport.cgi, sun.io.unicode.encoding=UnicodeLittle, sun.cpu.endian=little, dialect=org.hibernate.dialect.SQLServerDialect, sun.cpu.isalist=pentium i486 i386}
12:05:58,814 DEBUG Configuration:1035 - Preparing to build session factory with filters : {}
12:05:58,829 INFO Configuration:844 - processing extends queue
12:05:58,829 INFO Configuration:848 - processing collection mappings
12:05:58,829 DEBUG HbmBinder:2264 - Second pass for collection: com.yash.hibernate.Person.personQualifications
12:05:58,829 DEBUG HbmBinder:1086 - Mapped property: collegeStudied -> collegeStudied
12:05:58,829 DEBUG HbmBinder:1086 - Mapped property: qualification -> qualification
12:05:58,829 DEBUG HbmBinder:2280 - Mapped collection key: id, element: collegeStudied, qualification
12:05:58,829 DEBUG HbmBinder:2264 - Second pass for collection: com.yash.hibernate.Person.emailAddresses
12:05:58,829 DEBUG HbmBinder:2280 - Mapped collection key: id, element: EMAIL_ADDRESS
12:05:58,829 INFO Configuration:857 - processing association property references
12:05:58,829 INFO Configuration:884 - processing foreign key constraints
12:05:58,829 DEBUG Configuration:928 - resolving reference to class: com.yash.hibernate.Person
12:05:58,829 DEBUG Configuration:928 - resolving reference to class: com.yash.hibernate.Person
12:05:59,111 INFO Dialect:89 - Using dialect: org.hibernate.dialect.SQLServerDialect
12:05:59,126 DEBUG SQLExceptionConverterFactory:52 - Using dialect defined converter
12:05:59,126 INFO SettingsFactory:90 - Default batch fetch size: 1
12:05:59,126 INFO SettingsFactory:94 - Generate SQL with comments: disabled
12:05:59,126 INFO SettingsFactory:98 - Order SQL updates by primary key: disabled
12:05:59,126 INFO SettingsFactory:273 - Query translator: org.hibernate.hql.ast.ASTQueryTranslatorFactory
12:05:59,126 INFO ASTQueryTranslatorFactory:21 - Using ASTQueryTranslatorFactory
12:05:59,126 INFO SettingsFactory:106 - Query language substitutions: {}
12:05:59,142 INFO DriverManagerConnectionProvider:41 - Using Hibernate built-in connection pool (not for production use!)
12:05:59,142 INFO DriverManagerConnectionProvider:42 - Hibernate connection pool size: 10
12:05:59,142 INFO DriverManagerConnectionProvider:45 - autocommit mode: false
12:05:59,142 INFO DriverManagerConnectionProvider:80 - using driver: com.microsoft.jdbc.sqlserver.SQLServerDriver at URL: jdbc:microsoft:sqlserver://10.7.100.146:1433;databasename=YashTraining
12:05:59,142 INFO DriverManagerConnectionProvider:83 - connection properties: {user=trainingyash, password=trainingyash}
12:05:59,142 DEBUG DriverManagerConnectionProvider:93 - total checked-out connections: 0
12:05:59,142 DEBUG DriverManagerConnectionProvider:109 - opening new JDBC connection
12:05:59,298 DEBUG DriverManagerConnectionProvider:115 - created connection to: jdbc:microsoft:sqlserver://10.7.100.146:1433;databasename=YashTraining, Isolation Level: 2
12:05:59,329 DEBUG DriverManagerConnectionProvider:129 - returning connection to pool, pool size: 1
12:05:59,329 INFO SettingsFactory:156 - Scrollable result sets: enabled
12:05:59,329 DEBUG SettingsFactory:160 - Wrap result sets: disabled
12:05:59,329 INFO SettingsFactory:164 - JDBC3 getGeneratedKeys(): disabled
12:05:59,329 INFO TransactionFactoryFactory:31 - Using default transaction strategy (direct JDBC transactions)
12:05:59,345 INFO TransactionManagerLookupFactory:33 - No TransactionManagerLookup configured (in JTA environment, use of read-write or transactional second-level cache is not recommended)
12:05:59,345 INFO SettingsFactory:176 - Automatic flush during beforeCompletion(): disabled
12:05:59,345 INFO SettingsFactory:179 - Automatic session close at end of transaction: disabled
12:05:59,345 INFO SettingsFactory:260 - Cache provider: org.hibernate.cache.EhCacheProvider
12:05:59,345 INFO SettingsFactory:187 - Second-level cache: enabled
12:05:59,345 INFO SettingsFactory:192 - Optimize cache for minimal puts: disabled
12:05:59,345 INFO SettingsFactory:199 - Structured second-level cache entries: enabled
12:05:59,361 INFO SettingsFactory:203 - Query cache: disabled
12:05:59,361 INFO SettingsFactory:210 - Echoing all SQL to stdout
12:05:59,361 INFO SettingsFactory:214 - Statistics: disabled
12:05:59,361 INFO SettingsFactory:218 - Deleted entity synthetic identifier rollback: disabled
12:05:59,361 INFO SettingsFactory:232 - Default entity-mode: pojo
12:05:59,470 INFO SessionFactoryImpl:140 - building session factory
12:05:59,470 DEBUG SessionFactoryImpl:149 - Session factory constructed with filter configurations : {}
12:05:59,486 DEBUG SessionFactoryImpl:152 - instantiating session factory with properties: {hibernate.connection.password=trainingyash, java.runtime.name=Java(TM) 2 Runtime Environment, Standard Edition, sun.boot.library.path=C:\j2sdk1.4.0_02\jre\bin, java.vm.version=1.4.0_02-b02, hibernate.connection.username=trainingyash, 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.os.patch.level=Service Pack 4, java.vm.specification.name=Java Virtual Machine Specification, user.dir=D:\ServletHibernate\ComponentTest, java.runtime.version=1.4.0_02-b02, java.awt.graphicsenv=sun.awt.Win32GraphicsEnvironment, java.endorsed.dirs=C:\j2sdk1.4.0_02\jre\lib\endorsed, os.arch=x86, java.io.tmpdir=C:\DOCUME~1\vandanat\LOCALS~1\Temp\, line.separator=
, java.vm.specification.vendor=Sun Microsystems Inc., user.variant=, os.name=Windows 2000, sun.java2d.fontpath=, java.library.path=C:\j2sdk1.4.0_02\bin;.;C:\WINNT\system32;C:\WINNT;C:\Program Files\IBM\WebSphere Studio\Application Developer\v5.1.1\eclipse\jre\bin;C:\WINNT\system32;C:\WINNT;C:\WINNT\System32\Wbem;C:\PROGRA~1\IBM\IMNNQ;C:\Program Files\SQLLIB\BIN;C:\Program Files\SQLLIB\FUNCTION;C:\Program Files\SQLLIB\SAMPLES\REPL;C:\Program Files\SQLLIB\HELP;C:\Program Files\Microsoft SQL Server\80\Tools\BINN, java.specification.name=Java Platform API Specification, java.class.version=48.0, hibernate.connection.pool_size=10, java.util.prefs.PreferencesFactory=java.util.prefs.WindowsPreferencesFactory, os.version=5.0, user.home=C:\Documents and Settings\vandanat, user.timezone=GMT+05:30, java.awt.printerjob=sun.awt.windows.WPrinterJob, file.encoding=Cp1252, java.specification.version=1.4, hibernate.connection.driver_class=com.microsoft.jdbc.sqlserver.SQLServerDriver, show_sql=true, user.name=vandanat, java.class.path=D:\ServletHibernate\ComponentTest\classes;D:\ServletHibernate\ComponentTest\lib\antlr-2.7.6.jar;D:\ServletHibernate\ComponentTest\lib\asm.jar;D:\ServletHibernate\ComponentTest\lib\asm-attrs.jar;D:\ServletHibernate\ComponentTest\lib\cglib-2.1.3.jar;D:\ServletHibernate\ComponentTest\lib\cglib-nodep-2.1_2.jar;D:\ServletHibernate\ComponentTest\lib\commons-collections-2.1.1.jar;D:\ServletHibernate\ComponentTest\lib\commons-logging-1.0.4.jar;D:\ServletHibernate\ComponentTest\lib\dom4j-1.5.2.jar;D:\ServletHibernate\ComponentTest\lib\ehcache-1.1.jar;D:\ServletHibernate\ComponentTest\lib\hibernate3.jar;D:\ServletHibernate\ComponentTest\lib\jdbc2_0-stdext.jar;D:\ServletHibernate\ComponentTest\lib\jta.jar;D:\ServletHibernate\ComponentTest\lib\log4j-1.2.9.jar;D:\ServletHibernate\ComponentTest\lib\msbase.jar;D:\ServletHibernate\ComponentTest\lib\mssqlserver.jar;D:\ServletHibernate\ComponentTest\lib\msutil.jar;D:\ServletHibernate\ComponentTest\lib\xerces-2.6.2.jar;D:\ServletHibernate\ComponentTest\lib\xml-apis.jar, hibernate.show_sql=true, java.vm.specification.version=1.0, java.home=C:\j2sdk1.4.0_02\jre, sun.arch.data.model=32, hibernate.dialect=org.hibernate.dialect.SQLServerDialect, hibernate.connection.url=jdbc:microsoft:sqlserver://10.7.100.146:1433;databasename=YashTraining, user.language=en, java.specification.vendor=Sun Microsystems Inc., awt.toolkit=sun.awt.windows.WToolkit, hibernate.cglib.use_reflection_optimizer=true, java.vm.info=mixed mode, java.version=1.4.0_02, java.ext.dirs=C:\j2sdk1.4.0_02\jre\lib\ext, sun.boot.class.path=C:\j2sdk1.4.0_02\jre\lib\rt.jar;C:\j2sdk1.4.0_02\jre\lib\i18n.jar;C:\j2sdk1.4.0_02\jre\lib\sunrsasign.jar;C:\j2sdk1.4.0_02\jre\lib\jsse.jar;C:\j2sdk1.4.0_02\jre\lib\jce.jar;C:\j2sdk1.4.0_02\jre\lib\charsets.jar;C:\j2sdk1.4.0_02\jre\classes, java.vendor=Sun Microsystems Inc., file.separator=\, hibernate.hbm2ddl.auto=update, java.vendor.url.bug=http://java.sun.com/cgi-bin/bugreport.cgi, sun.io.unicode.encoding=UnicodeLittle, sun.cpu.endian=little, dialect=org.hibernate.dialect.SQLServerDialect, sun.cpu.isalist=pentium i486 i386}
12:05:59,486 WARN Configurator:126 - No configuration found. Configuring ehcache from ehcache-failsafe.xml found in the classpath: jar:file:/D:/ServletHibernate/ComponentTest/lib/ehcache-1.1.jar!/ehcache-failsafe.xml
12:05:59,782 DEBUG BasicEntityPersister:2191 - Static SQL for entity: com.yash.hibernate.Person
12:05:59,782 DEBUG BasicEntityPersister:2193 - Version select: select pid from person_Y where pid =?
12:05:59,782 DEBUG BasicEntityPersister:2194 - Snapshot select: select person_.pid, person_.birthday as birthday0_, person_.initial as initial0_, person_.first as first0_, person_.last as last0_ from person_Y person_ where person_.pid=?
12:05:59,782 DEBUG BasicEntityPersister:2196 - Insert 0: insert into person_Y (birthday, initial, first, last, pid) values (?, ?, ?, ?, ?)
12:05:59,782 DEBUG BasicEntityPersister:2197 - Update 0: update person_Y set birthday=?, initial=?, first=?, last=? where pid=?
12:05:59,782 DEBUG BasicEntityPersister:2198 - Delete 0: delete from person_Y where pid=?
12:05:59,798 DEBUG AbstractCollectionPersister:475 - Static SQL for collection: com.yash.hibernate.Person.personQualifications
12:05:59,798 DEBUG AbstractCollectionPersister:476 - Row insert: insert into PersonQualifications_Y (id, collegeStudied, qualification) values (?, ?, ?)
12:05:59,798 DEBUG AbstractCollectionPersister:477 - Row update: update PersonQualifications_Y set collegeStudied=?, qualification=? where id=? and collegeStudied=? and qualification=?
12:05:59,798 DEBUG AbstractCollectionPersister:478 - Row delete: delete from PersonQualifications_Y where id=? and collegeStudied=? and qualification=?
12:05:59,798 DEBUG AbstractCollectionPersister:479 - One-shot delete: delete from PersonQualifications_Y where id=?
12:05:59,814 DEBUG AbstractCollectionPersister:475 - Static SQL for collection: com.yash.hibernate.Person.emailAddresses
12:05:59,814 DEBUG AbstractCollectionPersister:476 - Row insert: insert into PersonEmailAddresses_Y (id, EMAIL_ADDRESS) values (?, ?)
12:05:59,814 DEBUG AbstractCollectionPersister:477 - Row update: update PersonEmailAddresses_Y set EMAIL_ADDRESS=? where id=? and EMAIL_ADDRESS=?
12:05:59,814 DEBUG AbstractCollectionPersister:478 - Row delete: delete from PersonEmailAddresses_Y where id=? and EMAIL_ADDRESS=?
12:05:59,814 DEBUG AbstractCollectionPersister:479 - One-shot delete: delete from PersonEmailAddresses_Y where id=?
12:05:59,829 DEBUG EntityLoader:118 - Static select for entity com.yash.hibernate.Person: select person0_.pid as pid0_, person0_.birthday as birthday0_0_, person0_.initial as initial0_0_, person0_.first as first0_0_, person0_.last as last0_0_ from person_Y person0_ where person0_.pid=?
12:05:59,829 DEBUG EntityLoader:118 - Static select for entity com.yash.hibernate.Person: select person0_.pid as pid0_, person0_.birthday as birthday0_0_, person0_.initial as initial0_0_, person0_.first as first0_0_, person0_.last as last0_0_ from person_Y person0_ where person0_.pid=?
12:05:59,829 DEBUG EntityLoader:118 - Static select for entity com.yash.hibernate.Person: select person0_.pid as pid0_, person0_.birthday as birthday0_0_, person0_.initial as initial0_0_, person0_.first as first0_0_, person0_.last as last0_0_ from person_Y person0_ where person0_.pid=?
12:05:59,845 DEBUG EntityLoader:118 - Static select for entity com.yash.hibernate.Person: select person0_.pid as pid0_, person0_.birthday as birthday0_0_, person0_.initial as initial0_0_, person0_.first as first0_0_, person0_.last as last0_0_ from person_Y person0_ where person0_.pid=?
12:05:59,845 DEBUG CollectionLoader:70 - Static select for collection com.yash.hibernate.Person.personQualifications: select personqual0_.id as id__, personqual0_.collegeStudied as collegeS2___, personqual0_.qualification as qualific3___ from PersonQualifications_Y personqual0_ where personqual0_.id=?
12:05:59,845 DEBUG CollectionLoader:70 - Static select for collection com.yash.hibernate.Person.emailAddresses: select emailaddre0_.id as id__, emailaddre0_.EMAIL_ADDRESS as EMAIL2___ from PersonEmailAddresses_Y emailaddre0_ where emailaddre0_.id=?
12:05:59,845 DEBUG SessionFactoryObjectFactory:39 - initializing class SessionFactoryObjectFactory
12:05:59,845 DEBUG SessionFactoryObjectFactory:76 - registered: 8a87e4040fc7c5b2010fc7c5b3e50000 (unnamed)
12:05:59,845 INFO SessionFactoryObjectFactory:82 - Not binding factory to JNDI, no JNDI name configured
12:05:59,845 DEBUG SessionFactoryImpl:249 - instantiated session factory
12:05:59,861 INFO Dialect:89 - Using dialect: org.hibernate.dialect.SQLServerDialect
12:05:59,861 INFO DriverManagerConnectionProvider:41 - Using Hibernate built-in connection pool (not for production use!)
12:05:59,861 INFO DriverManagerConnectionProvider:42 - Hibernate connection pool size: 10
12:05:59,861 INFO DriverManagerConnectionProvider:45 - autocommit mode: false
12:05:59,861 INFO DriverManagerConnectionProvider:80 - using driver: com.microsoft.jdbc.sqlserver.SQLServerDriver at URL: jdbc:microsoft:sqlserver://10.7.100.146:1433;databasename=YashTraining
12:05:59,861 INFO DriverManagerConnectionProvider:83 - connection properties: {user=trainingyash, password=trainingyash}
12:05:59,861 INFO SchemaUpdate:105 - Running hbm2ddl schema update
12:05:59,861 INFO SchemaUpdate:117 - fetching database metadata
12:05:59,861 DEBUG DriverManagerConnectionProvider:93 - total checked-out connections: 0
12:05:59,861 DEBUG DriverManagerConnectionProvider:109 - opening new JDBC connection
12:05:59,876 DEBUG DriverManagerConnectionProvider:115 - created connection to: jdbc:microsoft:sqlserver://10.7.100.146:1433;databasename=YashTraining, Isolation Level: 2
12:05:59,892 INFO SchemaUpdate:133 - updating schema
12:05:59,892 INFO Configuration:844 - processing extends queue
12:05:59,892 INFO Configuration:848 - processing collection mappings
12:05:59,892 INFO Configuration:857 - processing association property references
12:05:59,892 INFO Configuration:884 - processing foreign key constraints
12:05:59,892 DEBUG Configuration:928 - resolving reference to class: com.yash.hibernate.Person
12:05:59,892 DEBUG Configuration:928 - resolving reference to class: com.yash.hibernate.Person
12:06:00,032 INFO TableMetadata:38 - table found: YashTraining.trainingyash.PersonEmailAddresses_Y
12:06:00,032 INFO TableMetadata:39 - columns: [email_address, id]
12:06:00,032 INFO TableMetadata:40 - foreign keys: [fk37ccab55dd007370]
12:06:00,032 INFO TableMetadata:41 - indexes: []
12:06:00,095 INFO TableMetadata:38 - table found: YashTraining.trainingyash.PersonQualifications_Y
12:06:00,095 INFO TableMetadata:39 - columns: [collegestudied, qualification, id]
12:06:00,095 INFO TableMetadata:40 - foreign keys: [fk266fe4d3dd007370]
12:06:00,095 INFO TableMetadata:41 - indexes: []
12:06:00,142 INFO TableMetadata:38 - table found: YashTraining.trainingyash.person_Y
12:06:00,142 INFO TableMetadata:39 - columns: [last, first, initial, pid, birthday]
12:06:00,142 INFO TableMetadata:40 - foreign keys: []
12:06:00,142 INFO TableMetadata:41 - indexes: [pk__person_y__6da3c67f]
12:06:00,142 INFO SchemaUpdate:153 - schema update complete
12:06:00,142 INFO DriverManagerConnectionProvider:147 - cleaning up connection pool: jdbc:microsoft:sqlserver://10.7.100.146:1433;databasename=YashTraining
12:06:00,157 INFO SessionFactoryImpl:366 - Checking 0 named queries
Inserting Record
12:06:00,189 DEBUG SessionImpl:229 - opened session
12:06:00,189 DEBUG JDBCTransaction:46 - begin
12:06:00,189 DEBUG AbstractBatcher:379 - opening JDBC connection
12:06:00,189 DEBUG DriverManagerConnectionProvider:93 - total checked-out connections: 0
12:06:00,189 DEBUG DriverManagerConnectionProvider:99 - using pooled JDBC connection, pool size: 0
12:06:00,189 DEBUG JDBCTransaction:50 - current autocommit status: false
12:06:00,204 DEBUG DefaultLoadEventListener:193 - loading entity: [com.yash.hibernate.Person#1]
12:06:00,204 DEBUG DefaultLoadEventListener:240 - creating new proxy for entity
12:06:00,204 DEBUG DefaultLoadEventListener:326 - attempting to resolve: [com.yash.hibernate.Person#1]
12:06:00,204 DEBUG DefaultLoadEventListener:362 - object not resolved in any cache: [com.yash.hibernate.Person#1]
12:06:00,204 DEBUG BasicEntityPersister:2449 - Materializing entity: [com.yash.hibernate.Person#1]
12:06:00,204 DEBUG Loader:1250 - loading entity: [com.yash.hibernate.Person#1]
12:06:00,220 DEBUG AbstractBatcher:258 - about to open PreparedStatement (open PreparedStatements: 0, globally: 0)
12:06:00,220 DEBUG SQL:292 - select person0_.pid as pid0_, person0_.birthday as birthday0_0_, person0_.initial as initial0_0_, person0_.first as first0_0_, person0_.last as last0_0_ from person_Y person0_ where person0_.pid=?
Hibernate: select person0_.pid as pid0_, person0_.birthday as birthday0_0_, person0_.initial as initial0_0_, person0_.first as first0_0_, person0_.last as last0_0_ from person_Y person0_ where person0_.pid=?
12:06:00,220 DEBUG AbstractBatcher:343 - preparing statement
12:06:00,236 DEBUG IntegerType:59 - binding '1' to parameter: 1
12:06:00,251 DEBUG AbstractBatcher:274 - about to open ResultSet (open ResultSets: 0, globally: 0)
12:06:00,251 DEBUG Loader:377 - processing result set
12:06:00,251 DEBUG Loader:382 - result set row: 0
12:06:00,251 DEBUG Loader:719 - result row: EntityKey[com.yash.hibernate.Person#1]
12:06:00,251 DEBUG Loader:864 - Initializing object from ResultSet: [com.yash.hibernate.Person#1]
12:06:00,251 DEBUG BasicEntityPersister:1625 - Hydrating entity: [com.yash.hibernate.Person#1]
12:06:00,267 DEBUG DateType:86 - returning '28 December 2006' as column: birthday0_0_
12:06:00,282 DEBUG CharacterType:86 - returning 'J' as column: initial0_0_
12:06:00,282 DEBUG StringType:86 - returning 'joy' as column: first0_0_
12:06:00,282 DEBUG StringType:86 - returning 'shah' as column: last0_0_
12:06:00,282 DEBUG Loader:399 - done processing result set (1 rows)
12:06:00,282 DEBUG AbstractBatcher:281 - about to close ResultSet (open ResultSets: 1, globally: 1)
12:06:00,282 DEBUG AbstractBatcher:266 - about to close PreparedStatement (open PreparedStatements: 1, globally: 1)
12:06:00,282 DEBUG AbstractBatcher:363 - closing statement
12:06:00,282 DEBUG Loader:450 - total objects hydrated: 1
12:06:00,282 DEBUG TwoPhaseLoad:96 - resolving associations for [com.yash.hibernate.Person#1]
12:06:00,298 DEBUG CollectionLoadContext:134 - creating collection wrapper:[com.yash.hibernate.Person.personQualifications#1]
12:06:00,298 DEBUG CollectionLoadContext:134 - creating collection wrapper:[com.yash.hibernate.Person.emailAddresses#1]
12:06:00,298 DEBUG TwoPhaseLoad:167 - done materializing entity [com.yash.hibernate.Person#1]
12:06:00,298 DEBUG PersistenceContext:738 - initializing non-lazy collections
12:06:00,298 DEBUG Loader:1278 - done entity load
12:06:00,298 DEBUG DefaultDeleteEventListener:90 - deleting a persistent instance
12:06:00,298 DEBUG DefaultDeleteEventListener:125 - deleting [com.yash.hibernate.Person#1]
12:06:00,314 DEBUG SessionImpl:999 - setting cache mode to: GET
12:06:00,314 DEBUG Cascades:806 - processing cascade ACTION_DELETE for: com.yash.hibernate.Person
12:06:00,314 DEBUG Cascades:831 - done processing cascade ACTION_DELETE for: com.yash.hibernate.Person
12:06:00,314 DEBUG SessionImpl:999 - setting cache mode to: NORMAL
12:06:00,314 DEBUG SessionImpl:999 - setting cache mode to: GET
12:06:00,314 DEBUG Cascades:806 - processing cascade ACTION_DELETE for: com.yash.hibernate.Person
12:06:00,314 DEBUG Cascades:831 - done processing cascade ACTION_DELETE for: com.yash.hibernate.Person
12:06:00,314 DEBUG SessionImpl:999 - setting cache mode to: NORMAL
12:06:00,314 DEBUG JDBCTransaction:83 - commit
12:06:00,314 DEBUG SessionImpl:292 - automatically flushing session
12:06:00,314 DEBUG AbstractFlushingEventListener:52 - flushing session
12:06:00,314 DEBUG AbstractFlushingEventListener:102 - processing flush-time cascades
12:06:00,314 DEBUG AbstractFlushingEventListener:150 - dirty checking collections
12:06:00,314 DEBUG AbstractFlushingEventListener:167 - Flushing entities and processing referenced collections
12:06:00,329 DEBUG AbstractFlushingEventListener:203 - Processing unreferenced collections
12:06:00,329 DEBUG Collections:38 - Collection dereferenced: [com.yash.hibernate.Person.personQualifications#1]
12:06:00,329 DEBUG Collections:38 - Collection dereferenced: [com.yash.hibernate.Person.emailAddresses#1]
12:06:00,329 DEBUG AbstractFlushingEventListener:217 - Scheduling collection removes/(re)creates/updates
12:06:00,329 DEBUG AbstractFlushingEventListener:79 - Flushed: 0 insertions, 0 updates, 1 deletions to 1 objects
12:06:00,329 DEBUG AbstractFlushingEventListener:85 - Flushed: 0 (re)creations, 0 updates, 2 removals to 2 collections
12:06:00,345 DEBUG Printer:83 - listing entities:
12:06:00,345 DEBUG Printer:90 - com.yash.hibernate.Person{personQualifications=<uninitialized>, emailAddresses=<uninitialized>, Name=component[initial,first,last]{last=shah, first=joy, initial=J}, id=1, birthday=28 December 2006}
12:06:00,345 DEBUG AbstractFlushingEventListener:267 - executing flush
12:06:00,345 DEBUG AbstractCollectionPersister:769 - Deleting collection: [com.yash.hibernate.Person.personQualifications#1]
12:06:00,345 DEBUG AbstractBatcher:258 - about to open PreparedStatement (open PreparedStatements: 0, globally: 0)
12:06:00,345 DEBUG SQL:292 - delete from PersonQualifications_Y where id=?
Hibernate: delete from PersonQualifications_Y where id=?
12:06:00,345 DEBUG AbstractBatcher:343 - preparing statement
12:06:00,345 DEBUG IntegerType:59 - binding '1' to parameter: 1
12:06:00,345 DEBUG AbstractCollectionPersister:796 - done deleting collection
12:06:00,345 DEBUG AbstractCollectionPersister:769 - Deleting collection: [com.yash.hibernate.Person.emailAddresses#1]
12:06:00,345 DEBUG AbstractBatcher:266 - about to close PreparedStatement (open PreparedStatements: 1, globally: 1)
12:06:00,345 DEBUG AbstractBatcher:363 - closing statement
12:06:00,345 DEBUG AbstractBatcher:258 - about to open PreparedStatement (open PreparedStatements: 0, globally: 0)
12:06:00,345 DEBUG SQL:292 - delete from PersonEmailAddresses_Y where id=?
Hibernate: delete from PersonEmailAddresses_Y where id=?
12:06:00,345 DEBUG AbstractBatcher:343 - preparing statement
12:06:00,345 DEBUG IntegerType:59 - binding '1' to parameter: 1
12:06:00,345 DEBUG AbstractCollectionPersister:796 - done deleting collection
12:06:00,345 DEBUG AbstractBatcher:266 - about to close PreparedStatement (open PreparedStatements: 1, globally: 1)
12:06:00,345 DEBUG AbstractBatcher:363 - closing statement
12:06:00,361 DEBUG BasicEntityPersister:1997 - Deleting entity: [com.yash.hibernate.Person#1]
12:06:00,361 DEBUG AbstractBatcher:258 - about to open PreparedStatement (open PreparedStatements: 0, globally: 0)
12:06:00,361 DEBUG SQL:292 - delete from person_Y where pid=?
Hibernate: delete from person_Y where pid=?
12:06:00,361 DEBUG AbstractBatcher:343 - preparing statement
12:06:00,361 DEBUG IntegerType:59 - binding '1' to parameter: 1
12:06:00,361 DEBUG AbstractBatcher:266 - about to close PreparedStatement (open PreparedStatements: 1, globally: 1)
12:06:00,361 DEBUG AbstractBatcher:363 - closing statement
12:06:00,361 DEBUG AbstractFlushingEventListener:294 - post flush
12:06:00,361 DEBUG JDBCContext:208 - before transaction completion
12:06:00,361 DEBUG SessionImpl:337 - before transaction completion
12:06:00,361 DEBUG JDBCTransaction:96 - committed JDBC Connection
12:06:00,361 DEBUG JDBCContext:213 - after transaction completion
12:06:00,361 DEBUG SessionImpl:353 - after transaction completion
12:06:00,361 DEBUG SessionImpl:246 - closing session
12:06:00,361 DEBUG AbstractBatcher:394 - closing JDBC connection (open PreparedStatements: 0, globally: 0) (open ResultSets: 0, globally: 0)
12:06:00,361 DEBUG JDBCExceptionReporter:26 - SQL Warning
java.sql.SQLWarning: [Microsoft][SQLServer 2000 Driver for JDBC]Database changed to YashTraining
at com.microsoft.jdbc.base.BaseWarnings.createSQLWarning(Unknown Source)
at com.microsoft.jdbc.base.BaseWarnings.get(Unknown Source)
at com.microsoft.jdbc.base.BaseConnection.getWarnings(Unknown Source)
at org.hibernate.jdbc.AbstractBatcher.closeConnection(AbstractBatcher.java:404)
at org.hibernate.jdbc.JDBCContext.disconnect(JDBCContext.java:173)
at org.hibernate.jdbc.JDBCContext.release(JDBCContext.java:81)
at org.hibernate.impl.SessionImpl.close(SessionImpl.java:266)
at com.yash.hibernate.ComponentTest.main(ComponentTest.java:54)
12:06:00,376 WARN JDBCExceptionReporter:34 - SQL Warning: 0, SQLState:
12:06:00,376 WARN JDBCExceptionReporter:35 - [Microsoft][SQLServer 2000 Driver for JDBC]Database changed to YashTraining
12:06:00,376 WARN JDBCExceptionReporter:34 - SQL Warning: 0, SQLState:
12:06:00,376 WARN JDBCExceptionReporter:35 - [Microsoft][SQLServer 2000 Driver for JDBC][SQLServer]Changed database context to 'YashTraining'.
12:06:00,376 WARN JDBCExceptionReporter:34 - SQL Warning: 0, SQLState:
12:06:00,376 WARN JDBCExceptionReporter:35 - [Microsoft][SQLServer 2000 Driver for JDBC]Language changed to us_english
12:06:00,376 WARN JDBCExceptionReporter:34 - SQL Warning: 0, SQLState:
12:06:00,376 WARN JDBCExceptionReporter:35 - [Microsoft][SQLServer 2000 Driver for JDBC][SQLServer]Changed language setting to us_english.
12:06:00,376 DEBUG DriverManagerConnectionProvider:129 - returning connection to pool, pool size: 1
12:06:00,376 DEBUG JDBCContext:213 - after transaction completion
12:06:00,376 DEBUG SessionImpl:353 - after transaction completion



after having used componenet mapping, i am facing the problem that if i try updating the object of Person class, it deletes the object itself
i want to know is the record created using component mapping immutable or i'm making some mistake ?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jan 09, 2007 6:46 pm 
Regular
Regular

Joined: Wed Dec 07, 2005 4:19 pm
Posts: 53
Quote:
Code between sessionFactory.openSession() and session.close():
session =sessionFactory.openSession();
Person person=(Person)session.load(Person.class,new Integer(1));
//Iterator itr=
person.getPersonQualifications().add(new PersonQualification("asd", "asd"));
session.save(person);
session.flush();
session.close();


I assume your PersonQualification has a (back) reference to Person.
In the sample above:
person.getPersonQualifications().add(new PersonQualification(...)

I do not see anything telling (the new) PersonQualification that it is (now) attached to the instance of 'person' above, something like:
Code:
newPersonQualification.setPerson(person);


Don't forget to rate this posting - if it helped!
Martin


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.