-->
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.  [ 12 posts ] 
Author Message
 Post subject: testing hibernate
PostPosted: Tue Feb 21, 2006 10:39 pm 
Beginner
Beginner

Joined: Mon Dec 05, 2005 2:59 am
Posts: 31
i have wrritten a testService. java to insert the records into the Service table. the testService.java is as shown below:

package test;

import hibernate.ThreadLocalSession;
import model.Service;
import model.User;

import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;


public class testService {

/*
* Hibernate example to inset data into User table
*/
public static void main(String[] args) {
Session ses = null;

try{
SessionFactory sessionFactory = new Configuration().configure().buildSessionFactory();
ses =sessionFactory.openSession();
org.hibernate.Transaction tx = ses.beginTransaction();

//Create new instance of User and set values in it by reading them from form object
System.out.println("Inserting Record");
Service service = new Service();

service.setServiceId("002");
service.setRequireDate(null);
service.setIssueDate(null);
service.setState("1");
service.setServiceRemarks("abc");
service.setService("def");
User user = new User();
user.addUserInfo(service);
user.setEmpNo("001");//user assigned.
service.setEmpNo(user);
user.setFirstName("Ben");
user.setLastName("m");
user.setCompany("sy");
user.setDepartment("mis");
ses.save(service);
System.out.println("Done");
tx.commit();
ses.flush();
ses.close();
}catch(Exception e){
System.out.println(e.getMessage());
}
}
}


the output shown in the console is as follow:

Feb 22, 2006 10:12:42 AM org.hibernate.cfg.Environment <clinit>
INFO: Hibernate 3.0.5
Feb 22, 2006 10:12:42 AM org.hibernate.cfg.Environment <clinit>
INFO: hibernate.properties not found
Feb 22, 2006 10:12:42 AM org.hibernate.cfg.Environment <clinit>
INFO: using CGLIB reflection optimizer
Feb 22, 2006 10:12:42 AM org.hibernate.cfg.Environment <clinit>
INFO: using JDK 1.4 java.sql.Timestamp handling
Feb 22, 2006 10:12:42 AM org.hibernate.cfg.Configuration configure
INFO: configuring from resource: /hibernate.cfg.xml
Feb 22, 2006 10:12:42 AM org.hibernate.cfg.Configuration getConfigurationInputStream
INFO: Configuration resource: /hibernate.cfg.xml
Feb 22, 2006 10:12:42 AM org.hibernate.cfg.Configuration addResource
INFO: Mapping resource: model/User.hbm.xml
Feb 22, 2006 10:12:43 AM org.hibernate.cfg.HbmBinder bindRootPersistentClassCommonValues
INFO: Mapping class: model.User -> USER
Feb 22, 2006 10:12:43 AM org.hibernate.cfg.Configuration addResource
INFO: Mapping resource: model/Service.hbm.xml
Feb 22, 2006 10:12:43 AM org.hibernate.cfg.HbmBinder bindRootPersistentClassCommonValues
INFO: Mapping class: model.Service -> SERVICE
Feb 22, 2006 10:12:43 AM org.hibernate.cfg.Configuration addResource
INFO: Mapping resource: model/Authorizer.hbm.xml
Feb 22, 2006 10:12:43 AM org.hibernate.cfg.HbmBinder bindRootPersistentClassCommonValues
INFO: Mapping class: model.Authorizer -> AUTHORIZER
Feb 22, 2006 10:12:43 AM org.hibernate.cfg.Configuration addResource
INFO: Mapping resource: model/Company.hbm.xml
Feb 22, 2006 10:12:43 AM org.hibernate.cfg.HbmBinder bindRootPersistentClassCommonValues
INFO: Mapping class: model.Company -> COMPANY
Feb 22, 2006 10:12:43 AM org.hibernate.cfg.Configuration addResource
INFO: Mapping resource: model/ServiceType.hbm.xml
Feb 22, 2006 10:12:43 AM org.hibernate.cfg.HbmBinder bindRootPersistentClassCommonValues
INFO: Mapping class: model.ServiceType -> SERVICE_TYPE
Feb 22, 2006 10:12:43 AM org.hibernate.cfg.Configuration doConfigure
INFO: Configured SessionFactory: null
Feb 22, 2006 10:12:43 AM org.hibernate.cfg.Configuration secondPassCompile
INFO: processing extends queue
Feb 22, 2006 10:12:43 AM org.hibernate.cfg.Configuration secondPassCompile
INFO: processing collection mappings
Feb 22, 2006 10:12:43 AM org.hibernate.cfg.HbmBinder bindCollectionSecondPass
INFO: Mapping collection: model.User.userInfo -> SERVICE
Feb 22, 2006 10:12:43 AM org.hibernate.cfg.HbmBinder bindCollectionSecondPass
INFO: Mapping collection: model.Service.serviceInfo -> AUTHORIZER
Feb 22, 2006 10:12:43 AM org.hibernate.cfg.Configuration secondPassCompile
INFO: processing association property references
Feb 22, 2006 10:12:43 AM org.hibernate.cfg.Configuration secondPassCompile
INFO: processing foreign key constraints
Feb 22, 2006 10:12:43 AM org.hibernate.connection.DriverManagerConnectionProvider configure
INFO: Using Hibernate built-in connection pool (not for production use!)
Feb 22, 2006 10:12:43 AM org.hibernate.connection.DriverManagerConnectionProvider configure
INFO: Hibernate connection pool size: 10
Feb 22, 2006 10:12:43 AM org.hibernate.connection.DriverManagerConnectionProvider configure
INFO: autocommit mode: false
Feb 22, 2006 10:12:43 AM org.hibernate.connection.DriverManagerConnectionProvider configure
INFO: using driver: com.mysql.jdbc.Driver at URL: jdbc:mysql://localhost/symis
Feb 22, 2006 10:12:43 AM org.hibernate.connection.DriverManagerConnectionProvider configure
INFO: connection properties: {user=user, password=****}
Feb 22, 2006 10:12:43 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: RDBMS: MySQL, version: 4.1.13-nt
Feb 22, 2006 10:12:43 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: JDBC driver: MySQL-AB JDBC Driver, version: mysql-connector-java-3.1.11 ( $Date: 2005-09-21 18:20:03 +0000 (Wed, 21 Sep 2005) $, $Revision: 4287 $ )
Feb 22, 2006 10:12:43 AM org.hibernate.dialect.Dialect <init>
INFO: Using dialect: org.hibernate.dialect.MySQLDialect
Feb 22, 2006 10:12:43 AM org.hibernate.transaction.TransactionFactoryFactory buildTransactionFactory
INFO: Using default transaction strategy (direct JDBC transactions)
Feb 22, 2006 10:12:43 AM org.hibernate.transaction.TransactionManagerLookupFactory getTransactionManagerLookup
INFO: No TransactionManagerLookup configured (in JTA environment, use of read-write or transactional second-level cache is not recommended)
Feb 22, 2006 10:12:43 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Automatic flush during beforeCompletion(): disabled
Feb 22, 2006 10:12:43 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Automatic session close at end of transaction: disabled
Feb 22, 2006 10:12:43 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: JDBC batch size: 15
Feb 22, 2006 10:12:43 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: JDBC batch updates for versioned data: disabled
Feb 22, 2006 10:12:43 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Scrollable result sets: enabled
Feb 22, 2006 10:12:43 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: JDBC3 getGeneratedKeys(): enabled
Feb 22, 2006 10:12:43 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Connection release mode: null
Feb 22, 2006 10:12:43 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Maximum outer join fetch depth: 2
Feb 22, 2006 10:12:43 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Default batch fetch size: 1
Feb 22, 2006 10:12:43 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Generate SQL with comments: disabled
Feb 22, 2006 10:12:43 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Order SQL updates by primary key: disabled
Feb 22, 2006 10:12:43 AM org.hibernate.cfg.SettingsFactory createQueryTranslatorFactory
INFO: Query translator: org.hibernate.hql.ast.ASTQueryTranslatorFactory
Feb 22, 2006 10:12:43 AM org.hibernate.hql.ast.ASTQueryTranslatorFactory <init>
INFO: Using ASTQueryTranslatorFactory
Feb 22, 2006 10:12:43 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Query language substitutions: {}
Feb 22, 2006 10:12:43 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Second-level cache: enabled
Feb 22, 2006 10:12:43 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Query cache: disabled
Feb 22, 2006 10:12:43 AM org.hibernate.cfg.SettingsFactory createCacheProvider
INFO: Cache provider: org.hibernate.cache.EhCacheProvider
Feb 22, 2006 10:12:43 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Optimize cache for minimal puts: disabled
Feb 22, 2006 10:12:43 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Structured second-level cache entries: disabled
Feb 22, 2006 10:12:43 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Echoing all SQL to stdout
Feb 22, 2006 10:12:43 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Statistics: disabled
Feb 22, 2006 10:12:43 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Deleted entity synthetic identifier rollback: disabled
Feb 22, 2006 10:12:43 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Default entity-mode: pojo
Feb 22, 2006 10:12:43 AM org.hibernate.impl.SessionFactoryImpl <init>
INFO: building session factory
Feb 22, 2006 10:12:43 AM net.sf.ehcache.config.Configurator configure
WARNING: No configuration found. Configuring ehcache from ehcache-failsafe.xml found in the classpath: jar:file:/D:/eclipse/plugins/hibernate-2.1/lib/ehcache-0.9.jar!/ehcache-failsafe.xml
Feb 22, 2006 10:12:44 AM org.hibernate.impl.SessionFactoryObjectFactory addInstance
INFO: Not binding factory to JNDI, no JNDI name configured
Feb 22, 2006 10:12:44 AM org.hibernate.dialect.Dialect <init>
INFO: Using dialect: org.hibernate.dialect.MySQLDialect
Feb 22, 2006 10:12:44 AM org.hibernate.connection.DriverManagerConnectionProvider configure
INFO: Using Hibernate built-in connection pool (not for production use!)
Feb 22, 2006 10:12:44 AM org.hibernate.connection.DriverManagerConnectionProvider configure
INFO: Hibernate connection pool size: 10
Feb 22, 2006 10:12:44 AM org.hibernate.connection.DriverManagerConnectionProvider configure
INFO: autocommit mode: false
Feb 22, 2006 10:12:44 AM org.hibernate.connection.DriverManagerConnectionProvider configure
INFO: using driver: com.mysql.jdbc.Driver at URL: jdbc:mysql://localhost/symis
Feb 22, 2006 10:12:44 AM org.hibernate.connection.DriverManagerConnectionProvider configure
INFO: connection properties: {user=user, password=****}
Feb 22, 2006 10:12:44 AM org.hibernate.tool.hbm2ddl.SchemaUpdate execute
INFO: Running hbm2ddl schema update
Feb 22, 2006 10:12:44 AM org.hibernate.tool.hbm2ddl.SchemaUpdate execute
INFO: fetching database metadata
Feb 22, 2006 10:12:44 AM org.hibernate.tool.hbm2ddl.SchemaUpdate execute
INFO: updating schema
Feb 22, 2006 10:12:44 AM org.hibernate.cfg.Configuration secondPassCompile
INFO: processing extends queue
Feb 22, 2006 10:12:44 AM org.hibernate.cfg.Configuration secondPassCompile
INFO: processing collection mappings
Feb 22, 2006 10:12:44 AM org.hibernate.cfg.Configuration secondPassCompile
INFO: processing association property references
Feb 22, 2006 10:12:44 AM org.hibernate.cfg.Configuration secondPassCompile
INFO: processing foreign key constraints
Feb 22, 2006 10:12:44 AM org.hibernate.tool.hbm2ddl.TableMetadata <init>
INFO: table found: symis.authorizer
Feb 22, 2006 10:12:44 AM org.hibernate.tool.hbm2ddl.TableMetadata <init>
INFO: columns: [service_id, autho_id, date, roles, service_info, name, autho_remarks]
Feb 22, 2006 10:12:44 AM org.hibernate.tool.hbm2ddl.TableMetadata <init>
INFO: foreign keys: [fk2_service_id]
Feb 22, 2006 10:12:44 AM org.hibernate.tool.hbm2ddl.TableMetadata <init>
INFO: indexes: [primary, fk2_service_id]
Feb 22, 2006 10:12:44 AM org.hibernate.tool.hbm2ddl.TableMetadata <init>
INFO: table found: symis.company
Feb 22, 2006 10:12:44 AM org.hibernate.tool.hbm2ddl.TableMetadata <init>
INFO: columns: [address2, tel_no, address3, address1, fax, name, company_id]
Feb 22, 2006 10:12:44 AM org.hibernate.tool.hbm2ddl.TableMetadata <init>
INFO: foreign keys: []
Feb 22, 2006 10:12:44 AM org.hibernate.tool.hbm2ddl.TableMetadata <init>
INFO: indexes: [primary]
Feb 22, 2006 10:12:44 AM org.hibernate.tool.hbm2ddl.TableMetadata <init>
INFO: table found: symis.service
Feb 22, 2006 10:12:44 AM org.hibernate.tool.hbm2ddl.TableMetadata <init>
INFO: columns: [require_date, service, emp_no, issue_date, service_id, service_remarks, user_info, state]
Feb 22, 2006 10:12:44 AM org.hibernate.tool.hbm2ddl.TableMetadata <init>
INFO: foreign keys: [fk1_emp_no]
Feb 22, 2006 10:12:44 AM org.hibernate.tool.hbm2ddl.TableMetadata <init>
INFO: indexes: [primary, fk1_emp_no]
Feb 22, 2006 10:12:44 AM org.hibernate.tool.hbm2ddl.TableMetadata <init>
INFO: table found: symis.service_type
Feb 22, 2006 10:12:44 AM org.hibernate.tool.hbm2ddl.TableMetadata <init>
INFO: columns: [service_type_id, description]
Feb 22, 2006 10:12:44 AM org.hibernate.tool.hbm2ddl.TableMetadata <init>
INFO: foreign keys: []
Feb 22, 2006 10:12:44 AM org.hibernate.tool.hbm2ddl.TableMetadata <init>
INFO: indexes: [primary]
Feb 22, 2006 10:12:44 AM org.hibernate.tool.hbm2ddl.TableMetadata <init>
INFO: table found: symis.user
Feb 22, 2006 10:12:44 AM org.hibernate.tool.hbm2ddl.TableMetadata <init>
INFO: columns: [emp_no, designation, ext_no, last_name, first_name, department, company]
Feb 22, 2006 10:12:44 AM org.hibernate.tool.hbm2ddl.TableMetadata <init>
INFO: foreign keys: []
Feb 22, 2006 10:12:44 AM org.hibernate.tool.hbm2ddl.TableMetadata <init>
INFO: indexes: [primary]
Feb 22, 2006 10:12:44 AM org.hibernate.tool.hbm2ddl.SchemaUpdate execute
INFO: schema update complete
Feb 22, 2006 10:12:44 AM org.hibernate.connection.DriverManagerConnectionProvider close
INFO: cleaning up connection pool: jdbc:mysql://localhost/symis
Feb 22, 2006 10:12:44 AM org.hibernate.impl.SessionFactoryImpl checkNamedQueries
INFO: Checking 0 named queries

Inserting Record
Hibernate: select user_.EMP_NO, user_.FIRST_NAME as FIRST2_0_, user_.LAST_NAME as LAST3_0_, user_.COMPANY as COMPANY0_, user_.DEPARTMENT as DEPARTMENT0_, user_.DESIGNATION as DESIGNAT6_0_, user_.EXT_NO as EXT7_0_ from USER user_ where user_.EMP_NO=?
Done
Hibernate: insert into SERVICE (REQUIRE_DATE, ISSUE_DATE, EMP_NO, USER_INFO, STATE, SERVICE_REMARKS, SERVICE, SERVICE_ID) values (?, ?, ?, ?, ?, ?, ?, ?)
null


i think my mapping file has problem: i attached my service.hbm.xml and model file service.java as below:

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

<hibernate-mapping
>
<class
name="model.Service"
table="SERVICE"
>

<id
name="serviceId"
column="SERVICE_ID"
type="java.lang.String"
>
<generator class="assigned">
<!--
To add non XDoclet generator parameters, create a file named
hibernate-generator-params-Service.xml
containing the additional parameters and place it in your merge dir.
-->
</generator>
</id>

<property
name="requireDate"
type="date"
update="true"
insert="true"
>
<column
name="REQUIRE_DATE"
/>
</property>

<property
name="issueDate"
type="date"
update="true"
insert="true"
>
<column
name="ISSUE_DATE"
/>
</property>

<many-to-one
name="empNo"
class="model.User"
cascade="none"
lazy="false"
update="true"
insert="true"
foreign-key="FK1_EMP_NO"
column="EMP_NO"
not-null="true"
/>

<property
name="sv_userInfo"
type="string"
update="true"
insert="true"
>
<column
name="USER_INFO"
/>

</property>

<property
name="state"
type="int"
update="true"
insert="true"
>
<column
name="STATE"
/>
</property>

<property
name="serviceRemarks"
type="string"
update="true"
insert="true"
>
<column
name="SERVICE_REMARKS"
/>
</property>

<property
name="service"
type="string"
update="true"
insert="true"
>
<column
name="SERVICE"
/>
</property>

<list
name="serviceInfo"
lazy="false"
inverse="true"
cascade="none"
>

<key
column="SERVICE_ID"
>
</key>

<index
column="SERVICE_INFO"
type="string"
/>

<one-to-many
class="model.Authorizer"
/>

</list>

<!--
To add non XDoclet property mappings, create a file named
hibernate-properties-Service.xml
containing the additional properties and place it in your merge dir.
-->

</class>

</hibernate-mapping>

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
package model;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

public class Service implements Serializable {

private String serviceId;
private Date requireDate;
private Date issueDate;
private User empNo;
private String state;
private String serviceRemarks;
private String service;
private String sv_userInfo;
private List serviceInfo = new ArrayList();


public List getServiceInfo() {
return serviceInfo;
}
public void setServiceInfo(List serviceInfo) {
this.serviceInfo = serviceInfo;
}

public Date getIssueDate() {
return issueDate;
}
public void setIssueDate(Date issueDate) {
this.issueDate = issueDate;
}

public String getServiceRemarks() {
return serviceRemarks;
}
public void setServiceRemarks(String serviceRemarks) {
this.serviceRemarks = serviceRemarks;
}
public Date getRequireDate() {
return requireDate;
}
public void setRequireDate(Date requireDate) {
this.requireDate = requireDate;
}
public String getService() {
return service;
}
public void setService(String service) {
this.service = service;
}
public String getServiceId() {
return serviceId;
}
public void setServiceId(String serviceId) {
this.serviceId = serviceId;
}
public String getState() {
return state;
}
public void setState(String state) {
this.state = state;
}
public String getSv_userInfo() {
return sv_userInfo;
}
public void setSv_userInfo(User userInfo) {
this.sv_userInfo = sv_userInfo;
}
public User getEmpNo() {
return empNo;
}
public void setEmpNo(User empNo) {
this.empNo = empNo;
}

}


any comments???


Top
 Profile  
 
 Post subject:
PostPosted: Wed Feb 22, 2006 8:39 am 
Senior
Senior

Joined: Tue May 10, 2005 9:00 am
Posts: 125
replace this in you code

catch(Exception e){
System.out.println(e.getMessage());
}


with this

catch(Exception e){
e.printStackTrace();
}


(an exception stating 'null' without the stacktrace is useless :) )


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 23, 2006 9:02 pm 
Beginner
Beginner

Joined: Mon Dec 05, 2005 2:59 am
Posts: 31
the output displayed in my console is:

Feb 24, 2006 8:51:59 AM org.hibernate.cfg.Environment <clinit>
INFO: Hibernate 3.0.5
Feb 24, 2006 8:51:59 AM org.hibernate.cfg.Environment <clinit>
INFO: hibernate.properties not found
Feb 24, 2006 8:51:59 AM org.hibernate.cfg.Environment <clinit>
INFO: using CGLIB reflection optimizer
Feb 24, 2006 8:51:59 AM org.hibernate.cfg.Environment <clinit>
INFO: using JDK 1.4 java.sql.Timestamp handling
Feb 24, 2006 8:51:59 AM org.hibernate.cfg.Configuration configure
INFO: configuring from resource: /hibernate.cfg.xml
Feb 24, 2006 8:51:59 AM org.hibernate.cfg.Configuration getConfigurationInputStream
INFO: Configuration resource: /hibernate.cfg.xml
Feb 24, 2006 8:51:59 AM org.hibernate.cfg.Configuration addResource
INFO: Mapping resource: model/User.hbm.xml
Feb 24, 2006 8:51:59 AM org.hibernate.cfg.HbmBinder bindRootPersistentClassCommonValues
INFO: Mapping class: model.User -> USER
Feb 24, 2006 8:51:59 AM org.hibernate.cfg.Configuration addResource
INFO: Mapping resource: model/Service.hbm.xml
Feb 24, 2006 8:51:59 AM org.hibernate.cfg.HbmBinder bindRootPersistentClassCommonValues
INFO: Mapping class: model.Service -> SERVICE
Feb 24, 2006 8:51:59 AM org.hibernate.cfg.Configuration addResource
INFO: Mapping resource: model/Authorizer.hbm.xml
Feb 24, 2006 8:51:59 AM org.hibernate.cfg.HbmBinder bindRootPersistentClassCommonValues
INFO: Mapping class: model.Authorizer -> AUTHORIZER
Feb 24, 2006 8:51:59 AM org.hibernate.cfg.Configuration addResource
INFO: Mapping resource: model/Company.hbm.xml
Feb 24, 2006 8:51:59 AM org.hibernate.cfg.HbmBinder bindRootPersistentClassCommonValues
INFO: Mapping class: model.Company -> COMPANY
Feb 24, 2006 8:51:59 AM org.hibernate.cfg.Configuration addResource
INFO: Mapping resource: model/ServiceType.hbm.xml
Feb 24, 2006 8:51:59 AM org.hibernate.cfg.HbmBinder bindRootPersistentClassCommonValues
INFO: Mapping class: model.ServiceType -> SERVICE_TYPE
Feb 24, 2006 8:51:59 AM org.hibernate.cfg.Configuration doConfigure
INFO: Configured SessionFactory: null
Feb 24, 2006 8:51:59 AM org.hibernate.cfg.Configuration secondPassCompile
INFO: processing extends queue
Feb 24, 2006 8:51:59 AM org.hibernate.cfg.Configuration secondPassCompile
INFO: processing collection mappings
Feb 24, 2006 8:51:59 AM org.hibernate.cfg.HbmBinder bindCollectionSecondPass
INFO: Mapping collection: model.User.userInfo -> SERVICE
Feb 24, 2006 8:51:59 AM org.hibernate.cfg.HbmBinder bindCollectionSecondPass
INFO: Mapping collection: model.Service.serviceInfo -> AUTHORIZER
Feb 24, 2006 8:51:59 AM org.hibernate.cfg.Configuration secondPassCompile
INFO: processing association property references
Feb 24, 2006 8:51:59 AM org.hibernate.cfg.Configuration secondPassCompile
INFO: processing foreign key constraints
Feb 24, 2006 8:51:59 AM org.hibernate.connection.DriverManagerConnectionProvider configure
INFO: Using Hibernate built-in connection pool (not for production use!)
Feb 24, 2006 8:51:59 AM org.hibernate.connection.DriverManagerConnectionProvider configure
INFO: Hibernate connection pool size: 10
Feb 24, 2006 8:51:59 AM org.hibernate.connection.DriverManagerConnectionProvider configure
INFO: autocommit mode: false
Feb 24, 2006 8:51:59 AM org.hibernate.connection.DriverManagerConnectionProvider configure
INFO: using driver: com.mysql.jdbc.Driver at URL: jdbc:mysql://localhost/symis
Feb 24, 2006 8:51:59 AM org.hibernate.connection.DriverManagerConnectionProvider configure
INFO: connection properties: {user=user, password=****}
Feb 24, 2006 8:52:00 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: RDBMS: MySQL, version: 4.1.13-nt
Feb 24, 2006 8:52:00 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: JDBC driver: MySQL-AB JDBC Driver, version: mysql-connector-java-3.1.11 ( $Date: 2005-09-21 18:20:03 +0000 (Wed, 21 Sep 2005) $, $Revision: 4287 $ )
Feb 24, 2006 8:52:00 AM org.hibernate.dialect.Dialect <init>
INFO: Using dialect: org.hibernate.dialect.MySQLDialect
Feb 24, 2006 8:52:00 AM org.hibernate.transaction.TransactionFactoryFactory buildTransactionFactory
INFO: Using default transaction strategy (direct JDBC transactions)
Feb 24, 2006 8:52:00 AM org.hibernate.transaction.TransactionManagerLookupFactory getTransactionManagerLookup
INFO: No TransactionManagerLookup configured (in JTA environment, use of read-write or transactional second-level cache is not recommended)
Feb 24, 2006 8:52:00 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Automatic flush during beforeCompletion(): disabled
Feb 24, 2006 8:52:00 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Automatic session close at end of transaction: disabled
Feb 24, 2006 8:52:00 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: JDBC batch size: 15
Feb 24, 2006 8:52:00 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: JDBC batch updates for versioned data: disabled
Feb 24, 2006 8:52:00 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Scrollable result sets: enabled
Feb 24, 2006 8:52:00 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: JDBC3 getGeneratedKeys(): enabled
Feb 24, 2006 8:52:00 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Connection release mode: null
Feb 24, 2006 8:52:00 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Maximum outer join fetch depth: 2
Feb 24, 2006 8:52:00 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Default batch fetch size: 1
Feb 24, 2006 8:52:00 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Generate SQL with comments: disabled
Feb 24, 2006 8:52:00 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Order SQL updates by primary key: disabled
Feb 24, 2006 8:52:00 AM org.hibernate.cfg.SettingsFactory createQueryTranslatorFactory
INFO: Query translator: org.hibernate.hql.ast.ASTQueryTranslatorFactory
Feb 24, 2006 8:52:00 AM org.hibernate.hql.ast.ASTQueryTranslatorFactory <init>
INFO: Using ASTQueryTranslatorFactory
Feb 24, 2006 8:52:00 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Query language substitutions: {}
Feb 24, 2006 8:52:00 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Second-level cache: enabled
Feb 24, 2006 8:52:00 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Query cache: disabled
Feb 24, 2006 8:52:00 AM org.hibernate.cfg.SettingsFactory createCacheProvider
INFO: Cache provider: org.hibernate.cache.EhCacheProvider
Feb 24, 2006 8:52:00 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Optimize cache for minimal puts: disabled
Feb 24, 2006 8:52:00 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Structured second-level cache entries: disabled
Feb 24, 2006 8:52:00 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Echoing all SQL to stdout
Feb 24, 2006 8:52:00 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Statistics: disabled
Feb 24, 2006 8:52:00 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Deleted entity synthetic identifier rollback: disabled
Feb 24, 2006 8:52:00 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Default entity-mode: pojo
Feb 24, 2006 8:52:00 AM org.hibernate.impl.SessionFactoryImpl <init>
INFO: building session factory
Feb 24, 2006 8:52:00 AM net.sf.ehcache.config.Configurator configure
WARNING: No configuration found. Configuring ehcache from ehcache-failsafe.xml found in the classpath: jar:file:/D:/eclipse/plugins/hibernate-2.1/lib/ehcache-0.9.jar!/ehcache-failsafe.xml
Feb 24, 2006 8:52:00 AM org.hibernate.impl.SessionFactoryObjectFactory addInstance
INFO: Not binding factory to JNDI, no JNDI name configured
Feb 24, 2006 8:52:00 AM org.hibernate.dialect.Dialect <init>
INFO: Using dialect: org.hibernate.dialect.MySQLDialect
Feb 24, 2006 8:52:00 AM org.hibernate.connection.DriverManagerConnectionProvider configure
INFO: Using Hibernate built-in connection pool (not for production use!)
Feb 24, 2006 8:52:00 AM org.hibernate.connection.DriverManagerConnectionProvider configure
INFO: Hibernate connection pool size: 10
Feb 24, 2006 8:52:00 AM org.hibernate.connection.DriverManagerConnectionProvider configure
INFO: autocommit mode: false
Feb 24, 2006 8:52:00 AM org.hibernate.connection.DriverManagerConnectionProvider configure
INFO: using driver: com.mysql.jdbc.Driver at URL: jdbc:mysql://localhost/symis
Feb 24, 2006 8:52:00 AM org.hibernate.connection.DriverManagerConnectionProvider configure
INFO: connection properties: {user=user, password=****}
Feb 24, 2006 8:52:00 AM org.hibernate.tool.hbm2ddl.SchemaUpdate execute
INFO: Running hbm2ddl schema update
Feb 24, 2006 8:52:00 AM org.hibernate.tool.hbm2ddl.SchemaUpdate execute
INFO: fetching database metadata
Feb 24, 2006 8:52:01 AM org.hibernate.tool.hbm2ddl.SchemaUpdate execute
INFO: updating schema
Feb 24, 2006 8:52:01 AM org.hibernate.cfg.Configuration secondPassCompile
INFO: processing extends queue
Feb 24, 2006 8:52:01 AM org.hibernate.cfg.Configuration secondPassCompile
INFO: processing collection mappings
Feb 24, 2006 8:52:01 AM org.hibernate.cfg.Configuration secondPassCompile
INFO: processing association property references
Feb 24, 2006 8:52:01 AM org.hibernate.cfg.Configuration secondPassCompile
INFO: processing foreign key constraints
Feb 24, 2006 8:52:01 AM org.hibernate.tool.hbm2ddl.TableMetadata <init>
INFO: table found: symis.authorizer
Feb 24, 2006 8:52:01 AM org.hibernate.tool.hbm2ddl.TableMetadata <init>
INFO: columns: [service_id, autho_id, date, roles, service_info, name, autho_remarks]
Feb 24, 2006 8:52:01 AM org.hibernate.tool.hbm2ddl.TableMetadata <init>
INFO: foreign keys: [fk2_service_id]
Feb 24, 2006 8:52:01 AM org.hibernate.tool.hbm2ddl.TableMetadata <init>
INFO: indexes: [primary, fk2_service_id]
Feb 24, 2006 8:52:01 AM org.hibernate.tool.hbm2ddl.TableMetadata <init>
INFO: table found: symis.company
Feb 24, 2006 8:52:01 AM org.hibernate.tool.hbm2ddl.TableMetadata <init>
INFO: columns: [address2, tel_no, address3, address1, fax, name, company_id]
Feb 24, 2006 8:52:01 AM org.hibernate.tool.hbm2ddl.TableMetadata <init>
INFO: foreign keys: []
Feb 24, 2006 8:52:01 AM org.hibernate.tool.hbm2ddl.TableMetadata <init>
INFO: indexes: [primary]
Feb 24, 2006 8:52:01 AM org.hibernate.tool.hbm2ddl.TableMetadata <init>
INFO: table found: symis.service
Feb 24, 2006 8:52:01 AM org.hibernate.tool.hbm2ddl.TableMetadata <init>
INFO: columns: [require_date, service, emp_no, issue_date, service_id, service_remarks, user_info, state]
Feb 24, 2006 8:52:01 AM org.hibernate.tool.hbm2ddl.TableMetadata <init>
INFO: foreign keys: [fk1_emp_no]
Feb 24, 2006 8:52:01 AM org.hibernate.tool.hbm2ddl.TableMetadata <init>
INFO: indexes: [primary, fk1_emp_no]
Feb 24, 2006 8:52:01 AM org.hibernate.tool.hbm2ddl.TableMetadata <init>
INFO: table found: symis.service_type
Feb 24, 2006 8:52:01 AM org.hibernate.tool.hbm2ddl.TableMetadata <init>
INFO: columns: [service_type_id, description]
Feb 24, 2006 8:52:01 AM org.hibernate.tool.hbm2ddl.TableMetadata <init>
INFO: foreign keys: []
Feb 24, 2006 8:52:01 AM org.hibernate.tool.hbm2ddl.TableMetadata <init>
INFO: indexes: [primary]
Feb 24, 2006 8:52:01 AM org.hibernate.tool.hbm2ddl.TableMetadata <init>
INFO: table found: symis.user
Feb 24, 2006 8:52:01 AM org.hibernate.tool.hbm2ddl.TableMetadata <init>
INFO: columns: [emp_no, designation, ext_no, last_name, first_name, department, company]
Feb 24, 2006 8:52:01 AM org.hibernate.tool.hbm2ddl.TableMetadata <init>
INFO: foreign keys: []
Feb 24, 2006 8:52:01 AM org.hibernate.tool.hbm2ddl.TableMetadata <init>
INFO: indexes: [primary]
Feb 24, 2006 8:52:01 AM org.hibernate.tool.hbm2ddl.SchemaUpdate execute
INFO: schema update complete
Feb 24, 2006 8:52:01 AM org.hibernate.connection.DriverManagerConnectionProvider close
INFO: cleaning up connection pool: jdbc:mysql://localhost/symis
Feb 24, 2006 8:52:01 AM org.hibernate.impl.SessionFactoryImpl checkNamedQueries
INFO: Checking 0 named queries
Inserting Record
Hibernate: select user_.EMP_NO, user_.FIRST_NAME as FIRST2_0_, user_.LAST_NAME as LAST3_0_, user_.COMPANY as COMPANY0_, user_.DEPARTMENT as DEPARTMENT0_, user_.DESIGNATION as DESIGNAT6_0_, user_.EXT_NO as EXT7_0_ from USER user_ where user_.EMP_NO=?
Done
Hibernate: insert into SERVICE (REQUIRE_DATE, ISSUE_DATE, EMP_NO, USER_INFO, STATE, SERVICE_REMARKS, SERVICE, SERVICE_ID) values (?, ?, ?, ?, ?, ?, ?, ?)
java.lang.ClassCastException
at org.hibernate.type.IntegerType.set(IntegerType.java:39)
at org.hibernate.type.NullableType.nullSafeSet(NullableType.java:62)
at org.hibernate.type.NullableType.nullSafeSet(NullableType.java:39)
at org.hibernate.persister.entity.BasicEntityPersister.dehydrate(BasicEntityPersister.java:1617)
at org.hibernate.persister.entity.BasicEntityPersister.dehydrate(BasicEntityPersister.java:1594)
at org.hibernate.persister.entity.BasicEntityPersister.insert(BasicEntityPersister.java:1850)
at org.hibernate.persister.entity.BasicEntityPersister.insert(BasicEntityPersister.java:2200)
at org.hibernate.action.EntityInsertAction.execute(EntityInsertAction.java:46)
at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:239)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:223)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:136)
at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:274)
at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:730)
at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:324)
at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:86)
at test.testService.main(testService.java:45)


what have happend actually??


Top
 Profile  
 
 Post subject:
PostPosted: Fri Feb 24, 2006 5:29 am 
Senior
Senior

Joined: Tue May 10, 2005 9:00 am
Posts: 125
As you see, a classcastexception when trying to manipulate an integer value:

<property
name="state"
type="int"
update="true"
insert="true"
>


private String state;


Obviously you have a flaw there :)


Top
 Profile  
 
 Post subject:
PostPosted: Mon Feb 27, 2006 8:37 pm 
Beginner
Beginner

Joined: Mon Dec 05, 2005 2:59 am
Posts: 31
yup, it's my mistake!! :P anyway, why the USER_INFO column in the database return a 'null' value as my intention is to display the user's details (from table USER) in that column?? for example, i have specified the emp_no as '001' in this way:
User user = new User();
user.addUserInfo(service);
user.setEmpNo("001");//user assigned.
service.setEmpNo(user);

am i missing something in my persistent class or mapping file??


Top
 Profile  
 
 Post subject:
PostPosted: Tue Feb 28, 2006 4:34 am 
Senior
Senior

Joined: Tue May 10, 2005 9:00 am
Posts: 125
moonny wrote:
yup, it's my mistake!! :P anyway, why the USER_INFO column in the database return a 'null' value as my intention is to display the user's details


Probably because your column USER_INFO is mapped to service.sv_userInfo and you never call setSv_userInfo
And even if you call it, probably because of those lines why does absolutely nothing (compiler should eventually issue a warning on this line).
Code:
public void setSv_userInfo(User userInfo) {
this.sv_userInfo = sv_userInfo;
}


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 01, 2006 3:52 am 
Beginner
Beginner

Joined: Mon Dec 05, 2005 2:59 am
Posts: 31
there is a warning shown in

public void setSv_userInfo(User userInfo) {
this.sv_userInfo = sv_userInfo;
}


so what should i do to insert the user info written in user table to the column sv_userInfo column in service table??


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 01, 2006 4:49 am 
Senior
Senior

Joined: Tue May 10, 2005 9:00 am
Posts: 125
moonny wrote:
there is a warning shown in

public void setSv_userInfo(User userInfo) {
this.sv_userInfo = sv_userInfo;
}


so what should i do to insert the user info written in user table to the column sv_userInfo column in service table??


Basic java programming error, it's not hibernate related. I could tell you what the error is, but that would waste the fun :D

Hint: when compiler issue a warning there is most of the time a very good reason it issue a warning! Read twice the compiler output.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 01, 2006 8:27 pm 
Beginner
Beginner

Joined: Tue Feb 07, 2006 10:39 pm
Posts: 46
correct in this way:

public void setSv_userInfo(User userInfo) {
this.sv_userInfo = userInfo;
}


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 01, 2006 8:34 pm 
Beginner
Beginner

Joined: Mon Dec 05, 2005 2:59 am
Posts: 31
yup, i have corrected it in this way.

public void setSv_userInfo(User userInfo) {
this.sv_userInfo = userInfo;
}


by the way, i have modity my testService.java in this way:

package test;

import model.Service;
import model.User;

import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;


public class testService {

/*
* Hibernate example to inset data into User table
*/
public static void main(String[] args) {
Session ses = null;

try{
SessionFactory sessionFactory = new Configuration().configure().buildSessionFactory();
ses =sessionFactory.openSession();
org.hibernate.Transaction tx = ses.beginTransaction();

//Create new instance of User and set values in it by reading them from form object
System.out.println("Inserting Record");
Service service = new Service();

service.setServiceId("002");
service.setRequireDate(null);
service.setIssueDate(null);
service.setState("1");
service.setServiceRemarks("abc");
service.setService("def");
User user = new User();
user.addUserInfo(service);
user.setEmpNo("001");//user assigned.
service.setEmpNo(user);
service.setSv_userInfo(user);
//user.setFirstName("Jenny");
//user.setLastName("m");
//user.setCompany("sy");
//user.setDepartment("mis");
ses.save(service);
System.out.println("Done");
tx.commit();
ses.flush();
ses.close();
}catch(Exception e){
e.printStackTrace();
//System.out.println(e.getMessage());
}
}
}

however the output shown as below:

Mar 2, 2006 8:23:23 AM org.hibernate.cfg.Environment <clinit>
INFO: Hibernate 3.0.5
Mar 2, 2006 8:23:23 AM org.hibernate.cfg.Environment <clinit>
INFO: hibernate.properties not found
Mar 2, 2006 8:23:23 AM org.hibernate.cfg.Environment <clinit>
INFO: using CGLIB reflection optimizer
Mar 2, 2006 8:23:23 AM org.hibernate.cfg.Environment <clinit>
INFO: using JDK 1.4 java.sql.Timestamp handling
Mar 2, 2006 8:23:23 AM org.hibernate.cfg.Configuration configure
INFO: configuring from resource: /hibernate.cfg.xml
Mar 2, 2006 8:23:23 AM org.hibernate.cfg.Configuration getConfigurationInputStream
INFO: Configuration resource: /hibernate.cfg.xml
Mar 2, 2006 8:23:23 AM org.hibernate.cfg.Configuration addResource
INFO: Mapping resource: model/User.hbm.xml
Mar 2, 2006 8:23:23 AM org.hibernate.cfg.HbmBinder bindRootPersistentClassCommonValues
INFO: Mapping class: model.User -> USER
Mar 2, 2006 8:23:23 AM org.hibernate.cfg.Configuration addResource
INFO: Mapping resource: model/Service.hbm.xml
Mar 2, 2006 8:23:23 AM org.hibernate.cfg.HbmBinder bindRootPersistentClassCommonValues
INFO: Mapping class: model.Service -> SERVICE
Mar 2, 2006 8:23:23 AM org.hibernate.cfg.Configuration addResource
INFO: Mapping resource: model/Authorizer.hbm.xml
Mar 2, 2006 8:23:23 AM org.hibernate.cfg.HbmBinder bindRootPersistentClassCommonValues
INFO: Mapping class: model.Authorizer -> AUTHORIZER
Mar 2, 2006 8:23:23 AM org.hibernate.cfg.Configuration addResource
INFO: Mapping resource: model/Company.hbm.xml
Mar 2, 2006 8:23:23 AM org.hibernate.cfg.HbmBinder bindRootPersistentClassCommonValues
INFO: Mapping class: model.Company -> COMPANY
Mar 2, 2006 8:23:23 AM org.hibernate.cfg.Configuration addResource
INFO: Mapping resource: model/ServiceType.hbm.xml
Mar 2, 2006 8:23:23 AM org.hibernate.cfg.HbmBinder bindRootPersistentClassCommonValues
INFO: Mapping class: model.ServiceType -> SERVICE_TYPE
Mar 2, 2006 8:23:23 AM org.hibernate.cfg.Configuration doConfigure
INFO: Configured SessionFactory: null
Mar 2, 2006 8:23:23 AM org.hibernate.cfg.Configuration secondPassCompile
INFO: processing extends queue
Mar 2, 2006 8:23:23 AM org.hibernate.cfg.Configuration secondPassCompile
INFO: processing collection mappings
Mar 2, 2006 8:23:23 AM org.hibernate.cfg.HbmBinder bindCollectionSecondPass
INFO: Mapping collection: model.User.userInfo -> SERVICE
Mar 2, 2006 8:23:23 AM org.hibernate.cfg.HbmBinder bindCollectionSecondPass
INFO: Mapping collection: model.Service.serviceInfo -> AUTHORIZER
Mar 2, 2006 8:23:23 AM org.hibernate.cfg.Configuration secondPassCompile
INFO: processing association property references
Mar 2, 2006 8:23:23 AM org.hibernate.cfg.Configuration secondPassCompile
INFO: processing foreign key constraints
Mar 2, 2006 8:23:23 AM org.hibernate.connection.DriverManagerConnectionProvider configure
INFO: Using Hibernate built-in connection pool (not for production use!)
Mar 2, 2006 8:23:23 AM org.hibernate.connection.DriverManagerConnectionProvider configure
INFO: Hibernate connection pool size: 10
Mar 2, 2006 8:23:23 AM org.hibernate.connection.DriverManagerConnectionProvider configure
INFO: autocommit mode: false
Mar 2, 2006 8:23:23 AM org.hibernate.connection.DriverManagerConnectionProvider configure
INFO: using driver: com.mysql.jdbc.Driver at URL: jdbc:mysql://localhost/symis
Mar 2, 2006 8:23:23 AM org.hibernate.connection.DriverManagerConnectionProvider configure
INFO: connection properties: {user=user, password=****}
Mar 2, 2006 8:23:24 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: RDBMS: MySQL, version: 4.1.13-nt
Mar 2, 2006 8:23:24 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: JDBC driver: MySQL-AB JDBC Driver, version: mysql-connector-java-3.1.11 ( $Date: 2005-09-21 18:20:03 +0000 (Wed, 21 Sep 2005) $, $Revision: 4287 $ )
Mar 2, 2006 8:23:24 AM org.hibernate.dialect.Dialect <init>
INFO: Using dialect: org.hibernate.dialect.MySQLDialect
Mar 2, 2006 8:23:24 AM org.hibernate.transaction.TransactionFactoryFactory buildTransactionFactory
INFO: Using default transaction strategy (direct JDBC transactions)
Mar 2, 2006 8:23:24 AM org.hibernate.transaction.TransactionManagerLookupFactory getTransactionManagerLookup
INFO: No TransactionManagerLookup configured (in JTA environment, use of read-write or transactional second-level cache is not recommended)
Mar 2, 2006 8:23:24 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Automatic flush during beforeCompletion(): disabled
Mar 2, 2006 8:23:24 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Automatic session close at end of transaction: disabled
Mar 2, 2006 8:23:24 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: JDBC batch size: 15
Mar 2, 2006 8:23:24 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: JDBC batch updates for versioned data: disabled
Mar 2, 2006 8:23:24 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Scrollable result sets: enabled
Mar 2, 2006 8:23:24 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: JDBC3 getGeneratedKeys(): enabled
Mar 2, 2006 8:23:24 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Connection release mode: null
Mar 2, 2006 8:23:24 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Maximum outer join fetch depth: 2
Mar 2, 2006 8:23:24 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Default batch fetch size: 1
Mar 2, 2006 8:23:24 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Generate SQL with comments: disabled
Mar 2, 2006 8:23:24 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Order SQL updates by primary key: disabled
Mar 2, 2006 8:23:24 AM org.hibernate.cfg.SettingsFactory createQueryTranslatorFactory
INFO: Query translator: org.hibernate.hql.ast.ASTQueryTranslatorFactory
Mar 2, 2006 8:23:24 AM org.hibernate.hql.ast.ASTQueryTranslatorFactory <init>
INFO: Using ASTQueryTranslatorFactory
Mar 2, 2006 8:23:24 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Query language substitutions: {}
Mar 2, 2006 8:23:24 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Second-level cache: enabled
Mar 2, 2006 8:23:24 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Query cache: disabled
Mar 2, 2006 8:23:24 AM org.hibernate.cfg.SettingsFactory createCacheProvider
INFO: Cache provider: org.hibernate.cache.EhCacheProvider
Mar 2, 2006 8:23:24 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Optimize cache for minimal puts: disabled
Mar 2, 2006 8:23:24 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Structured second-level cache entries: disabled
Mar 2, 2006 8:23:24 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Echoing all SQL to stdout
Mar 2, 2006 8:23:24 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Statistics: disabled
Mar 2, 2006 8:23:24 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Deleted entity synthetic identifier rollback: disabled
Mar 2, 2006 8:23:24 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Default entity-mode: pojo
Mar 2, 2006 8:23:24 AM org.hibernate.impl.SessionFactoryImpl <init>
INFO: building session factory
Mar 2, 2006 8:23:24 AM net.sf.ehcache.config.Configurator configure
WARNING: No configuration found. Configuring ehcache from ehcache-failsafe.xml found in the classpath: jar:file:/D:/eclipse/plugins/hibernate-2.1/lib/ehcache-0.9.jar!/ehcache-failsafe.xml
Mar 2, 2006 8:23:24 AM org.hibernate.impl.SessionFactoryObjectFactory addInstance
INFO: Not binding factory to JNDI, no JNDI name configured
Mar 2, 2006 8:23:24 AM org.hibernate.dialect.Dialect <init>
INFO: Using dialect: org.hibernate.dialect.MySQLDialect
Mar 2, 2006 8:23:24 AM org.hibernate.connection.DriverManagerConnectionProvider configure
INFO: Using Hibernate built-in connection pool (not for production use!)
Mar 2, 2006 8:23:24 AM org.hibernate.connection.DriverManagerConnectionProvider configure
INFO: Hibernate connection pool size: 10
Mar 2, 2006 8:23:24 AM org.hibernate.connection.DriverManagerConnectionProvider configure
INFO: autocommit mode: false
Mar 2, 2006 8:23:24 AM org.hibernate.connection.DriverManagerConnectionProvider configure
INFO: using driver: com.mysql.jdbc.Driver at URL: jdbc:mysql://localhost/symis
Mar 2, 2006 8:23:24 AM org.hibernate.connection.DriverManagerConnectionProvider configure
INFO: connection properties: {user=user, password=****}
Mar 2, 2006 8:23:24 AM org.hibernate.tool.hbm2ddl.SchemaUpdate execute
INFO: Running hbm2ddl schema update
Mar 2, 2006 8:23:24 AM org.hibernate.tool.hbm2ddl.SchemaUpdate execute
INFO: fetching database metadata
Mar 2, 2006 8:23:24 AM org.hibernate.tool.hbm2ddl.SchemaUpdate execute
INFO: updating schema
Mar 2, 2006 8:23:24 AM org.hibernate.cfg.Configuration secondPassCompile
INFO: processing extends queue
Mar 2, 2006 8:23:24 AM org.hibernate.cfg.Configuration secondPassCompile
INFO: processing collection mappings
Mar 2, 2006 8:23:24 AM org.hibernate.cfg.Configuration secondPassCompile
INFO: processing association property references
Mar 2, 2006 8:23:24 AM org.hibernate.cfg.Configuration secondPassCompile
INFO: processing foreign key constraints
Mar 2, 2006 8:23:24 AM org.hibernate.tool.hbm2ddl.TableMetadata <init>
INFO: table found: symis.authorizer
Mar 2, 2006 8:23:24 AM org.hibernate.tool.hbm2ddl.TableMetadata <init>
INFO: columns: [service_id, autho_id, date, roles, service_info, name, autho_remarks]
Mar 2, 2006 8:23:24 AM org.hibernate.tool.hbm2ddl.TableMetadata <init>
INFO: foreign keys: [fk2_service_id]
Mar 2, 2006 8:23:24 AM org.hibernate.tool.hbm2ddl.TableMetadata <init>
INFO: indexes: [primary, fk2_service_id]
Mar 2, 2006 8:23:24 AM org.hibernate.tool.hbm2ddl.TableMetadata <init>
INFO: table found: symis.company
Mar 2, 2006 8:23:24 AM org.hibernate.tool.hbm2ddl.TableMetadata <init>
INFO: columns: [address2, tel_no, address3, address1, fax, name, company_id]
Mar 2, 2006 8:23:24 AM org.hibernate.tool.hbm2ddl.TableMetadata <init>
INFO: foreign keys: []
Mar 2, 2006 8:23:24 AM org.hibernate.tool.hbm2ddl.TableMetadata <init>
INFO: indexes: [primary]
Mar 2, 2006 8:23:24 AM org.hibernate.tool.hbm2ddl.TableMetadata <init>
INFO: table found: symis.service
Mar 2, 2006 8:23:24 AM org.hibernate.tool.hbm2ddl.TableMetadata <init>
INFO: columns: [require_date, service, emp_no, issue_date, service_id, service_remarks, user_info, state]
Mar 2, 2006 8:23:24 AM org.hibernate.tool.hbm2ddl.TableMetadata <init>
INFO: foreign keys: [fk1_emp_no]
Mar 2, 2006 8:23:24 AM org.hibernate.tool.hbm2ddl.TableMetadata <init>
INFO: indexes: [primary, fk1_emp_no]
Mar 2, 2006 8:23:24 AM org.hibernate.tool.hbm2ddl.TableMetadata <init>
INFO: table found: symis.service_type
Mar 2, 2006 8:23:24 AM org.hibernate.tool.hbm2ddl.TableMetadata <init>
INFO: columns: [service_type_id, description]
Mar 2, 2006 8:23:24 AM org.hibernate.tool.hbm2ddl.TableMetadata <init>
INFO: foreign keys: []
Mar 2, 2006 8:23:24 AM org.hibernate.tool.hbm2ddl.TableMetadata <init>
INFO: indexes: [primary]
Mar 2, 2006 8:23:24 AM org.hibernate.tool.hbm2ddl.TableMetadata <init>
INFO: table found: symis.user
Mar 2, 2006 8:23:24 AM org.hibernate.tool.hbm2ddl.TableMetadata <init>
INFO: columns: [emp_no, designation, ext_no, last_name, first_name, department, company]
Mar 2, 2006 8:23:24 AM org.hibernate.tool.hbm2ddl.TableMetadata <init>
INFO: foreign keys: []
Mar 2, 2006 8:23:24 AM org.hibernate.tool.hbm2ddl.TableMetadata <init>
INFO: indexes: [primary]
Mar 2, 2006 8:23:24 AM org.hibernate.tool.hbm2ddl.SchemaUpdate execute
INFO: schema update complete
Mar 2, 2006 8:23:24 AM org.hibernate.connection.DriverManagerConnectionProvider close
INFO: cleaning up connection pool: jdbc:mysql://localhost/symis
Mar 2, 2006 8:23:24 AM org.hibernate.impl.SessionFactoryImpl checkNamedQueries
INFO: Checking 0 named queries
Inserting Record
Hibernate: select user_.EMP_NO, user_.FIRST_NAME as FIRST2_0_, user_.LAST_NAME as LAST3_0_, user_.COMPANY as COMPANY0_, user_.DEPARTMENT as DEPARTMENT0_, user_.DESIGNATION as DESIGNAT6_0_, user_.EXT_NO as EXT7_0_ from USER user_ where user_.EMP_NO=?
Done
Hibernate: insert into SERVICE (REQUIRE_DATE, ISSUE_DATE, EMP_NO, USER_INFO, STATE, SERVICE_REMARKS, SERVICE, SERVICE_ID) values (?, ?, ?, ?, ?, ?, ?, ?)
java.lang.ClassCastException
at org.hibernate.type.StringType.set(StringType.java:24)
at org.hibernate.type.NullableType.nullSafeSet(NullableType.java:62)
at org.hibernate.type.NullableType.nullSafeSet(NullableType.java:39)
at org.hibernate.persister.entity.BasicEntityPersister.dehydrate(BasicEntityPersister.java:1617)
at org.hibernate.persister.entity.BasicEntityPersister.dehydrate(BasicEntityPersister.java:1594)
at org.hibernate.persister.entity.BasicEntityPersister.insert(BasicEntityPersister.java:1850)
at org.hibernate.persister.entity.BasicEntityPersister.insert(BasicEntityPersister.java:2200)
at org.hibernate.action.EntityInsertAction.execute(EntityInsertAction.java:46)
at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:239)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:223)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:136)
at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:274)
at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:730)
at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:324)
at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:86)
at test.testService.main(testService.java:45)


seem like i cant even write my data into the service table. i know is somewhere at service.setSv_userInfo(user); got problem but i don't know how to fix it so that i can write the user info into the service table. help!!


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 02, 2006 6:24 am 
Senior
Senior

Joined: Tue May 10, 2005 9:00 am
Posts: 125
Same error as first one, you are declaring a field in your hbm which does not correspond in type to the class property.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 02, 2006 8:36 pm 
Beginner
Beginner

Joined: Mon Dec 05, 2005 2:59 am
Posts: 31
tchize wrote:
Same error as first one, you are declaring a field in your hbm which does not correspond in type to the class property.


my newly modified persistent class of user.java u is as below:

package model;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

public class User implements Serializable{
private String empNo;
private String firstName;
private String lastName;
private String company;
private String department;
private String designation;
private String extNo;
private List serviceInfo = new ArrayList();



public String getCompany() {
return company;
}
public void setCompany(String company) {
this.company = company;
}
public String getDepartment() {
return department;
}
public void setDepartment(String department) {
this.department = department;
}
public String getDesignation() {
return designation;
}
public void setDesignation(String designation) {
this.designation = designation;
}

public String getEmpNo() {
return empNo;
}
public void setEmpNo(String empNo) {

this.empNo = empNo;
}
public String getExtNo() {
return extNo;
}
public void setExtNo(String extNo) {
this.extNo = extNo;
}
public String getFirstName() {
return firstName;
}
public void setFirstName(String firstName) {
this.firstName = firstName;
}
public String getLastName() {
return lastName;
}
public void setLastName(String lastName) {
this.lastName = lastName;
}

public List getServiceInfo() {
return serviceInfo;
}
public void setServiceInfo(List v) {
this.serviceInfo = v;
}

public void addServiceInfo(Service v){
//this.getUserInfo().add(v);
v.setEmpNo(this);
serviceInfo.add(v);
}


}

service.java as below:

package model;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

public class Service implements Serializable {

private String serviceId;
private Date requireDate;
private Date issueDate;
private User empNo;
private String state;
private String serviceRemarks;
private String service;
private User sv_userInfo;
private List serviceInfo = new ArrayList();


public List getServiceInfo() {
return serviceInfo;
}
public void setServiceInfo(List v) {
this.serviceInfo = v;
}
public void addServiceInfo (Authorizer v){
v.setServiceId(this);
serviceInfo.add(v);
}

public Date getIssueDate() {
return issueDate;
}
public void setIssueDate(Date issueDate) {
this.issueDate = issueDate;
}

public String getServiceRemarks() {
return serviceRemarks;
}
public void setServiceRemarks(String serviceRemarks) {
this.serviceRemarks = serviceRemarks;
}
public Date getRequireDate() {
return requireDate;
}
public void setRequireDate(Date requireDate) {
this.requireDate = requireDate;
}
public String getService() {
return service;
}
public void setService(String service) {
this.service = service;
}
public String getServiceId() {
return serviceId;
}
public void setServiceId(String serviceId) {
this.serviceId = serviceId;
}
public String getState() {
return state;
}
public void setState(String state) {
this.state = state;
}
public User getSv_userInfo() {
return sv_userInfo;
}
public void setSv_userInfo(User userInfo) {
this.sv_userInfo = userInfo;
}
public User getEmpNo() {
return empNo;
}
public void setEmpNo(User empNo) {
this.empNo = empNo;
}

}


user.hbm.xml as below:

[color=dark blue]<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">

<hibernate-mapping
>
<class
name="model.User"
table="USER"
>

<id
name="empNo"
column="EMP_NO"
type="java.lang.String"
>
<generator class="assigned">
<!--
To add non XDoclet generator parameters, create a file named
hibernate-generator-params-User.xml
containing the additional parameters and place it in your merge dir.
-->
</generator>
</id>

<property
name="firstName"
type="string"
update="true"
insert="true"
>
<column
name="FIRST_NAME"
/>
</property>

<property
name="lastName"
type="string"
update="true"
insert="true"
>
<column
name="LAST_NAME"
/>
</property>

<property
name="company"
type="string"
update="true"
insert="true"
>
<column
name="COMPANY"
/>
</property>

<property
name="department"
type="string"
update="true"
insert="true"
>
<column
name="DEPARTMENT"
/>
</property>

<property
name="designation"
type="string"
update="true"
insert="true"
>
<column
name="DESIGNATION"
/>
</property>

<property
name="extNo"
type="string"
update="true"
insert="true"
>
<column
name="EXT_NO"
/>
</property>

<list
name="serviceInfo"
lazy="false"
inverse="true"
cascade="none"
>

<key
column="EMP_NO"
>
</key>

<index
column="SERVICE_INFO"
type="string"
/>

<one-to-many
class="model.Service"
/>

</list>


<!--
To add non XDoclet property mappings, create a file named
hibernate-properties-User.xml
containing the additional properties and place it in your merge dir.
-->

</class>

</hibernate-mapping>[/color]

service.hbm.xml:

[color=dark blue]<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">

<hibernate-mapping
>
<class
name="model.Service"
table="SERVICE"
>

<id
name="serviceId"
column="SERVICE_ID"
type="java.lang.String"
>
<generator class="assigned">
<!--
To add non XDoclet generator parameters, create a file named
hibernate-generator-params-Service.xml
containing the additional parameters and place it in your merge dir.
-->
</generator>
</id>

<property
name="requireDate"
type="date"
update="true"
insert="true"
>
<column
name="REQUIRE_DATE"
/>
</property>

<property
name="issueDate"
type="date"
update="true"
insert="true"
>
<column
name="ISSUE_DATE"
/>
</property>

<many-to-one
name="empNo"
class="model.User"
cascade="none"
lazy="false"
update="true"
insert="true"
foreign-key="FK1_EMP_NO"
column="EMP_NO"
not-null="false"
/>

<property
name="sv_userInfo"
type="string"
update="true"
insert="true"
>
<column
name="USER_INFO"
/>

</property>

<property
name="state"
type="string"
update="true"
insert="true"
>
<column
name="STATE"
/>
</property>

<property
name="serviceRemarks"
type="string"
update="true"
insert="true"
>
<column
name="SERVICE_REMARKS"
/>
</property>

<property
name="service"
type="string"
update="true"
insert="true"
>
<column
name="SERVICE"
/>
</property>

<list
name="serviceInfo"
lazy="false"
inverse="true"
cascade="none"
>

<key
column="SERVICE_ID"
>
</key>

<index
column="SERVICE_INFO"
type="string"
/>

<one-to-many
class="model.Authorizer"
/>

</list>

<!--
To add non XDoclet property mappings, create a file named
hibernate-properties-Service.xml
containing the additional properties and place it in your merge dir.
-->

</class>

</hibernate-mapping>[/color]

can anyone scan thrugh my files to figure out my mistakes?? this is my first hibernate project and i hope that i can do it successfully. :)


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