This is my code:
public DataSource createDataSource(String name)
DataSource dataSource = new DataSource();
dataSource.setName(name);
dataSource.setLastUpdateUserId(getLoggedInUser());
dataSource.setCreatedDate(Calendar.getInstance());
dataSource.setLastUpdateTimestamp(Calendar.getInstance());
if(canCreateDataSource(dataSource)) {
throw new DataSourceException("");
} else{
productionDao.createDataSource(dataSource);
}
return dataSource;
}
DAO:
public void createDataSource(DataSource dataSource) {
getHibernateTemplate().save(dataSource);
}
i was able to insert the first record successfully...the primary key is generated as
35000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
then i tried again to create another record then i got the following exception
Loading XML bean definitions from file [C:\WebService\WEB-INF\applicationContext.xml]
- Bean factory for application context [org.springframework.context.support.FileSystemXmlApplicationContext;hashCode=397372140]: org.springframework.beans.factory.support.DefaultListableBeanFactory defining beans [dataSource,sessionFactory,transactionManager,roleDao,userDao,workflowDao,productionDao,facade,userManagerTarget]; Root of BeanFactory hierarchy
- 9 beans defined in ApplicationContext [org.springframework.context.support.FileSystemXmlApplicationContext;hashCode=397372140]
- No MessageSource found for context [org.springframework.context.support.FileSystemXmlApplicationContext;hashCode=397372140]: using empty default
- No ApplicationEventMulticaster found for context [org.springframework.context.support.FileSystemXmlApplicationContext;hashCode=397372140]: using default
- Refreshing listeners
- Pre-instantiating singletons in factory [org.springframework.beans.factory.support.DefaultListableBeanFactory defining beans [dataSource,sessionFactory,transactionManager,roleDao,userDao,workflowDao,productionDao,facade,userManagerTarget]; Root of BeanFactory hierarchy]
- Creating shared instance of singleton bean 'dataSource'
- Loaded JDBC driver: oracle.jdbc.driver.OracleDriver
- Creating shared instance of singleton bean 'sessionFactory'
- Hibernate 2.1.6
- hibernate.properties not found
- using CGLIB reflection optimizer
- Mapping class: com.test.webservice.impl.User -> USER_DETAIL
- Mapping collection: com.test.webservice.impl.User.rolesSet -> USER_ROLE_MAP
- Mapping collection: com.test.webservice.impl.User.groupsSet -> USER_GROUP_MAP
- Mapping class: com.test.webservice.impl.Group -> GROUP_DETAIL
- Mapping collection: com.test.webservice.impl.Group.membersSet -> USER_GROUP_MAP
- Mapping collection: com.test.webservice.impl.Group.rolesSet -> GROUP_ROLE_MAP
- Mapping class: com.test.webservice.databean.SubGroup -> SUB_GROUP
- Mapping class: com.test.webservice.impl.Role -> ROLE
- Mapping collection: com.test.webservice.impl.Role.privilegesSet -> ROLE_PRIV_MAP
- Mapping class: com.test.webservice.impl.Privilege -> PRIVILEGE
- Mapping class: com.test.webservice.impl.Notification -> NOTIFICATION
- Mapping collection: com.test.webservice.impl.Notification.users -> NOTIFICATION_USERS
- Mapping collection: com.test.webservice.impl.Notification.groups -> NOTIFICATION_GROUP
- Mapping class: com.test.webservice.impl.State -> STATE
- Mapping collection: com.test.webservice.impl.State.notificationsSet -> STATE_NOTIFICATION
- Mapping class: com.test.webservice.databean.StateMap -> STATE_MAP
- Mapping class: com.test.webservice.impl.DataSource -> DATASOURCE
- Mapping collection: com.test.webservice.impl.DataSource.rolesSet -> DATASOURCE_ROLE_MAP
- Mapping collection: com.test.webservice.impl.DataSource.printJobsSet -> PRINTJOB_DATASOURC
- Mapping class: com.test.webservice.impl.PrintDevice -> PRINT_DEVICE
- Mapping class: com.test.webservice.databean.PrintJobDeviceMap -> PRINTJOB_PRINTDEV
- Mapping class: com.test.webservice.impl.PrintJob -> PRINTJOB
- Mapping collection: com.test.webservice.impl.PrintJob.dataSourcesSet -> PRINTJOB_DATASOURC
- Mapping class: com.test.webservice.impl.Publication -> PUBLICATION
- Mapping class: com.test.webservice.impl.Category -> CATEGORY
- Mapping class: com.test.webservice.databean.SubCategory -> SUB_CATEGORY
- Mapping class: com.test.webservice.impl.Annotation -> ANNOTATION
- Mapping class: com.test.webservice.databean.AnnotationMap -> ANNOTATION_MAP
- Mapping class: com.test.webservice.databean.CategoryMap -> CATEGORY_MAP
- Mapping class: com.test.webservice.databean.EntityType -> ENTITY_TYPE
- Mapping class: com.test.webservice.impl.AuditTrail -> AUDIT_TRAIL
- Mapping class: com.test.webservice.databean.SystemProperties -> SYSTEM_PROPERTIES
- Mapping class: com.test.webservice.databean.Properties -> PROPERTIES
- Building new Hibernate SessionFactory
- processing one-to-many association mappings
- Mapping collection: com.test.webservice.impl.Group.subgroupsSet -> SUB_GROUP
- Mapping collection: com.test.webservice.impl.Group.parentsSet -> SUB_GROUP
- Mapping collection: com.test.webservice.impl.PrintJob.printDevicesSet -> PRINTJOB_PRINTDEV
- Mapping collection: com.test.webservice.impl.Category.children -> SUB_CATEGORY
- Mapping collection: com.test.webservice.impl.Category.parents -> SUB_CATEGORY
- processing one-to-one association property references
- processing foreign key constraints
- Using dialect: net.sf.hibernate.dialect.OracleDialect
- Use outer join fetching: true
- Initializing connection provider: org.springframework.orm.hibernate.LocalDataSourceConnectionProvider
- No TransactionManagerLookup configured (in JTA environment, use of process level read-write cache is not recommended)
- Use scrollable result sets: true
- Use JDBC3 getGeneratedKeys(): false
- Optimize cache for minimal puts: false
- echoing all SQL to stdout
- Query language substitutions: {}
- cache provider: net.sf.hibernate.cache.EhCacheProvider
- instantiating and configuring caches
- building session factory
- Not binding factory to JNDI, no JNDI name configured
- Using dialect: net.sf.hibernate.dialect.OracleDialect
- Initializing connection provider: org.springframework.orm.hibernate.LocalDataSourceConnectionProvider
- Running hbm2ddl schema update
- fetching database metadata
- updating schema
- processing one-to-many association mappings
- processing one-to-one association property references
- processing foreign key constraints
- schema update complete
- Creating shared instance of singleton bean 'transactionManager'
- Using DataSource [org.springframework.jdbc.datasource.DriverManagerDataSource@3d302aed] of Hibernate SessionFactory for HibernateTransactionManager
- Creating shared instance of singleton bean 'roleDao'
- Loading XML bean definitions from class path resource [org/springframework/jdbc/support/sql-error-codes.xml]
- Creating shared instance of singleton bean 'DB2'
- Creating shared instance of singleton bean 'HSQL'
- Creating shared instance of singleton bean 'MS-SQL'
- Creating shared instance of singleton bean 'MySQL'
- Creating shared instance of singleton bean 'Oracle'
- Creating shared instance of singleton bean 'Informix'
- Creating shared instance of singleton bean 'PostgreSQL'
- Creating shared instance of singleton bean 'Sybase'
- SQLErrorCodes loaded: [HSQL Database Engine, Oracle, Sybase SQL Server, Microsoft SQL Server, Informix Dynamic Server, PostgreSQL, DB2*, MySQL]
- Looking up default SQLErrorCodes for DataSource
- Database Product Name is Oracle
- Driver Version is 9.2.0.3.0
- Creating shared instance of singleton bean 'userDao'
- Looking up default SQLErrorCodes for DataSource
- Database product name found in cache for DataSource [org.springframework.jdbc.datasource.DriverManagerDataSource@3d302aed]. Name is 'Oracle'.
- Creating shared instance of singleton bean 'workflowDao'
- Looking up default SQLErrorCodes for DataSource
- Database product name found in cache for DataSource [org.springframework.jdbc.datasource.DriverManagerDataSource@3d302aed]. Name is 'Oracle'.
- Creating shared instance of singleton bean 'productionDao'
- Looking up default SQLErrorCodes for DataSource
- Database product name found in cache for DataSource [org.springframework.jdbc.datasource.DriverManagerDataSource@3d302aed]. Name is 'Oracle'.
- Creating shared instance of singleton bean 'facade'
- Creating shared instance of singleton bean 'userManagerTarget'
Hibernate: select datasource0_.DATASOURCE_ID as DATASOUR1_, datasource0_.DATASOURCE_NAME as DATASOUR2_, datasource0_.CREATED_DATE as CREATED_3_, datasource0_.LAST_UPD_USER_ID as LAST_UPD4_, datasource0_.LAST_UPD_TIMESTAMP as LAST_UPD5_ from myschema.DATASOURCE datasource0_ where (datasource0_.DATASOURCE_NAME=? )
- SQL Error: 0, SQLState: null
- Overflow Exception
- Could not save object
java.sql.SQLException: Overflow Exception
at oracle.sql.NUMBER.toLong(NUMBER.java:376)
at oracle.jdbc.dbaccess.DBConversion.NumberBytesToLong(DBConversion.java:2915)
at oracle.jdbc.driver.OracleStatement.getLongValue(OracleStatement.java:4562)
at oracle.jdbc.driver.OracleResultSetImpl.getLong(OracleResultSetImpl.java:555)
at net.sf.hibernate.id.IncrementGenerator.getNext(IncrementGenerator.java:69)
at net.sf.hibernate.id.IncrementGenerator.generate(IncrementGenerator.java:42)
at net.sf.hibernate.impl.SessionImpl.saveWithGeneratedIdentifier(SessionImpl.java:765)
at net.sf.hibernate.impl.SessionImpl.save(SessionImpl.java:738)
at org.springframework.orm.hibernate.HibernateTemplate$11.doInHibernate(HibernateTemplate.java:301)
at org.springframework.orm.hibernate.HibernateTemplate.execute(HibernateTemplate.java:176)
at org.springframework.orm.hibernate.HibernateTemplate.save(HibernateTemplate.java:298)
at com.test.webservice.dao.ProductionDAO.createDataSource(ProductionDAO.java:88)
at com.test.webservice.ProductionServiceImpl.createDataSource(ProductionServiceImpl.java:791)
at com.test.webservice.ProductionServiceImpl.main(ProductionServiceImpl.java:1494)
- Unable to translate SQLException with errorCode '0', will now try the fallback translator
- Translating SQLException with SQLState 'null' and errorCode '0' and message [Overflow Exception]; SQL was [] for task [Hibernate operation]
Exception in thread "main" org.springframework.jdbc.UncategorizedSQLException: (Hibernate operation): encountered SQLException [Overflow Exception]; nested exception is java.sql.SQLException: Overflow Exception
java.sql.SQLException: Overflow Exception
at oracle.sql.NUMBER.toLong(NUMBER.java:376)
at oracle.jdbc.dbaccess.DBConversion.NumberBytesToLong(DBConversion.java:2915)
at oracle.jdbc.driver.OracleStatement.getLongValue(OracleStatement.java:4562)
at oracle.jdbc.driver.OracleResultSetImpl.getLong(OracleResultSetImpl.java:555)
at net.sf.hibernate.id.IncrementGenerator.getNext(IncrementGenerator.java:69)
at net.sf.hibernate.id.IncrementGenerator.generate(IncrementGenerator.java:42)
at net.sf.hibernate.impl.SessionImpl.saveWithGeneratedIdentifier(SessionImpl.java:765)
at net.sf.hibernate.impl.SessionImpl.save(SessionImpl.java:738)
at org.springframework.orm.hibernate.HibernateTemplate$11.doInHibernate(HibernateTemplate.java:301)
at org.springframework.orm.hibernate.HibernateTemplate.execute(HibernateTemplate.java:176)
at org.springframework.orm.hibernate.HibernateTemplate.save(HibernateTemplate.java:298)
at com.test.webservice.dao.ProductionDAO.createDataSource(ProductionDAO.java:88)
at com.test.webservice.ProductionServiceImpl.createDataSource(ProductionServiceImpl.java:791)
at com.test.webservice.ProductionServiceImpl.main(ProductionServiceImpl.java:1494)
|