Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

getting an error while using oneTOone mapping

 
kiran kumar reddy
Ranch Hand
Posts: 94
Eclipse IDE Java Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

i have done it correctly to my knowledge but still iam getting an error , i am using eclipse and mysql4.0 and the error is shown below

18:26:48,990 INFO Version:15 - Hibernate Annotations 3.4.0.GA
18:26:48,999 INFO Environment:560 - Hibernate 3.3.2.GA
18:26:49,000 INFO Environment:593 - hibernate.properties not found
18:26:49,002 INFO Environment:771 - Bytecode provider name : javassist
18:26:49,004 INFO Environment:652 - using JDK 1.4 java.sql.Timestamp handling
18:26:49,051 INFO Version:14 - Hibernate Commons Annotations 3.1.0.GA
18:26:49,057 INFO Configuration:1474 - configuring from resource: /hibernate.cfg.xml
18:26:49,057 INFO Configuration:1451 - Configuration resource: /hibernate.cfg.xml
18:26:49,108 INFO Configuration:1589 - Configured SessionFactory: null
18:26:49,122 INFO Dialect:175 - Using dialect: org.hibernate.dialect.MySQLDialect
18:26:49,176 INFO AnnotationBinder:419 - Binding entity from annotated class: com.hibernate.OnetoOneMapping.Person
18:26:49,198 INFO EntityBinder:422 - Bind entity com.hibernate.OnetoOneMapping.Person on table Person
18:26:49,230 INFO AnnotationBinder:419 - Binding entity from annotated class: com.hibernate.OnetoOneMapping.PersonDetail
18:26:49,231 INFO EntityBinder:422 - Bind entity com.hibernate.OnetoOneMapping.PersonDetail on table PersonDetail
18:26:49,247 INFO AnnotationConfiguration:369 - Hibernate Validator not found: ignoring
18:26:49,270 INFO SchemaExport:226 - Running hbm2ddl schema export
18:26:49,271 DEBUG SchemaExport:242 - import file not found: /import.sql
18:26:49,271 INFO SchemaExport:251 - exporting generated schema to database
18:26:49,273 INFO DriverManagerConnectionProvider:64 - Using Hibernate built-in connection pool (not for production use!)
18:26:49,273 INFO DriverManagerConnectionProvider:65 - Hibernate connection pool size: 2
18:26:49,273 INFO DriverManagerConnectionProvider:68 - autocommit mode: false
18:26:49,276 INFO DriverManagerConnectionProvider:103 - using driver: com.mysql.jdbc.Driver at URL: jdbc:mysql://localhost:3306/testDb
18:26:49,276 INFO DriverManagerConnectionProvider:109 - connection properties: {user=root, password=****}
alter table Person drop foreign key FK8E4887753CCF9E77
18:26:49,347 DEBUG SchemaExport:377 - alter table Person drop foreign key FK8E4887753CCF9E77
drop table if exists Person
18:26:49,423 DEBUG SchemaExport:377 - drop table if exists Person
drop table if exists PersonDetail
18:26:49,426 DEBUG SchemaExport:377 - drop table if exists PersonDetail
create table Person (personId integer not null auto_increment, personName varchar(255), pDetail_FK integer, primary key (personId))
18:26:49,427 DEBUG SchemaExport:377 - create table Person (personId integer not null auto_increment, personName varchar(255), pDetail_FK integer, primary key (personId))
create table PersonDetail (detailId-pk integer not null auto_increment, income double precision not null, job varchar(255), zipcode varchar(255), primary key (detailId-pk))
18:26:49,467 DEBUG SchemaExport:377 - create table PersonDetail (detailId-pk integer not null auto_increment, income double precision not null, job varchar(255), zipcode varchar(255), primary key (detailId-pk))
18:26:49,470 ERROR SchemaExport:348 - Unsuccessful: create table PersonDetail (detailId-pk integer not null auto_increment, income double precision not null, job varchar(255), zipcode varchar(255), primary key (detailId-pk))
18:26:49,470 ERROR SchemaExport:349 - Syntax error or access violation, message from server: "You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near '-pk integer not null auto_increment, income double precision no"
alter table Person add index FK8E4887753CCF9E77 (pDetail_FK), add constraint FK8E4887753CCF9E77 foreign key (pDetail_FK) references PersonDetail (detailId-pk)
18:26:49,470 DEBUG SchemaExport:377 - alter table Person add index FK8E4887753CCF9E77 (pDetail_FK), add constraint FK8E4887753CCF9E77 foreign key (pDetail_FK) references PersonDetail (detailId-pk)
18:26:49,471 ERROR SchemaExport:348 - Unsuccessful: alter table Person add index FK8E4887753CCF9E77 (pDetail_FK), add constraint FK8E4887753CCF9E77 foreign key (pDetail_FK) references PersonDetail (detailId-pk)
18:26:49,471 ERROR SchemaExport:349 - Syntax error or access violation, message from server: "You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near '-pk)' at line 1"
18:26:49,471 INFO SchemaExport:268 - schema export complete
18:26:49,472 INFO DriverManagerConnectionProvider:170 - cleaning up connection pool: jdbc:mysql://localhost:3306/testDb
18:26:49,476 INFO HibernateSearchEventListenerRegister:53 - Unable to find org.hibernate.search.event.FullTextIndexEventListener on the classpath. Hibernate Search is not enabled.
18:26:49,481 INFO DriverManagerConnectionProvider:64 - Using Hibernate built-in connection pool (not for production use!)
18:26:49,482 INFO DriverManagerConnectionProvider:65 - Hibernate connection pool size: 2
18:26:49,482 INFO DriverManagerConnectionProvider:68 - autocommit mode: false
18:26:49,482 INFO DriverManagerConnectionProvider:103 - using driver: com.mysql.jdbc.Driver at URL: jdbc:mysql://localhost:3306/testDb
18:26:49,482 INFO DriverManagerConnectionProvider:109 - connection properties: {user=root, password=****}
18:26:49,487 INFO SettingsFactory:114 - RDBMS: MySQL, version: 4.0.18-max-debug
18:26:49,487 INFO SettingsFactory:115 - JDBC driver: MySQL-AB JDBC Driver, version: mysql-connector-java-3.0.11-stable ( $Date: 2004/02/04 02:47:36 $, $Revision: 1.27.2.34 $ )
18:26:49,497 INFO Dialect:175 - Using dialect: org.hibernate.dialect.MySQLDialect
18:26:49,498 INFO TransactionFactoryFactory:59 - Using default transaction strategy (direct JDBC transactions)
18:26:49,500 INFO TransactionManagerLookupFactory:80 - No TransactionManagerLookup configured (in JTA environment, use of read-write or transactional second-level cache is not recommended)
18:26:49,500 INFO SettingsFactory:161 - Automatic flush during beforeCompletion(): disabled
18:26:49,500 INFO SettingsFactory:165 - Automatic session close at end of transaction: disabled
18:26:49,500 INFO SettingsFactory:172 - JDBC batch size: 15
18:26:49,500 INFO SettingsFactory:175 - JDBC batch updates for versioned data: disabled
18:26:49,501 INFO SettingsFactory:180 - Scrollable result sets: enabled
18:26:49,501 INFO SettingsFactory:188 - JDBC3 getGeneratedKeys(): enabled
18:26:49,501 INFO SettingsFactory:196 - Connection release mode: auto
18:26:49,502 INFO SettingsFactory:220 - Maximum outer join fetch depth: 2
18:26:49,502 INFO SettingsFactory:223 - Default batch fetch size: 1
18:26:49,502 INFO SettingsFactory:227 - Generate SQL with comments: disabled
18:26:49,502 INFO SettingsFactory:231 - Order SQL updates by primary key: disabled
18:26:49,502 INFO SettingsFactory:235 - Order SQL inserts for batching: disabled
18:26:49,502 INFO SettingsFactory:397 - Query translator: org.hibernate.hql.ast.ASTQueryTranslatorFactory
18:26:49,504 INFO ASTQueryTranslatorFactory:47 - Using ASTQueryTranslatorFactory
18:26:49,504 INFO SettingsFactory:243 - Query language substitutions: {}
18:26:49,504 INFO SettingsFactory:248 - JPA-QL strict compliance: disabled
18:26:49,504 INFO SettingsFactory:253 - Second-level cache: enabled
18:26:49,504 INFO SettingsFactory:257 - Query cache: disabled
18:26:49,508 INFO SettingsFactory:382 - Cache region factory : org.hibernate.cache.impl.bridge.RegionFactoryCacheProviderBridge
18:26:49,509 INFO RegionFactoryCacheProviderBridge:61 - Cache provider: org.hibernate.cache.NoCacheProvider
18:26:49,509 INFO SettingsFactory:267 - Optimize cache for minimal puts: disabled
18:26:49,509 INFO SettingsFactory:276 - Structured second-level cache entries: disabled
18:26:49,512 INFO SettingsFactory:296 - Echoing all SQL to stdout
18:26:49,512 INFO SettingsFactory:305 - Statistics: disabled
18:26:49,512 INFO SettingsFactory:309 - Deleted entity synthetic identifier rollback: disabled
18:26:49,513 INFO SettingsFactory:324 - Default entity-mode: pojo
18:26:49,513 INFO SettingsFactory:328 - Named query checking : enabled
18:26:49,534 INFO SessionFactoryImpl:193 - building session factory
18:26:49,638 INFO SessionFactoryObjectFactory:105 - Not binding factory to JNDI, no JNDI name configured
Hibernate: insert into PersonDetail (income, job, zipcode) values (?, ?, ?)
18:26:49,698 WARN JDBCExceptionReporter:100 - SQL Error: 1146, SQLState: S1000
Exception in thread "main" org.hibernate.exception.GenericJDBCException: could not insert: [com.hibernate.OnetoOneMapping.PersonDetail]
at org.hibernate.exception.SQLStateConverter.handledNonSpecificException(SQLStateConverter.java:126)
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:114)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:66)
at org.hibernate.id.insert.AbstractReturningDelegate.performInsert(AbstractReturningDelegate.java:64)
at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2176)
at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2656)
at org.hibernate.action.EntityIdentityInsertAction.execute(EntityIdentityInsertAction.java:71)
at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:279)18:26:49,698 ERROR JDBCExceptionReporter:101 - General error, message from server: "Table 'testdb.persondetail' doesn't exist"

at org.hibernate.event.def.AbstractSaveEventListener.performSaveOrReplicate(AbstractSaveEventListener.java:321)
at org.hibernate.event.def.AbstractSaveEventListener.performSave(AbstractSaveEventListener.java:204)
at org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:130)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:210)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:195)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.performSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:117)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:93)
at org.hibernate.impl.SessionImpl.fireSaveOrUpdate(SessionImpl.java:535)
at org.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java:527)
at org.hibernate.engine.CascadingAction$5.cascade(CascadingAction.java:241)
at org.hibernate.engine.Cascade.cascadeToOne(Cascade.java:292)
at org.hibernate.engine.Cascade.cascadeAssociation(Cascade.java:240)
at org.hibernate.engine.Cascade.cascadeProperty(Cascade.java:193)
at org.hibernate.engine.Cascade.cascade(Cascade.java:154)
at org.hibernate.event.def.AbstractSaveEventListener.cascadeBeforeSave(AbstractSaveEventListener.java:454)
at org.hibernate.event.def.AbstractSaveEventListener.performSaveOrReplicate(AbstractSaveEventListener.java:288)
at org.hibernate.event.def.AbstractSaveEventListener.performSave(AbstractSaveEventListener.java:204)
at org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:130)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:210)
at org.hibernate.event.def.DefaultSaveEventListener.saveWithGeneratedOrRequestedId(DefaultSaveEventListener.java:56)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:195)
at org.hibernate.event.def.DefaultSaveEventListener.performSaveOrUpdate(DefaultSaveEventListener.java:50)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:93)
at org.hibernate.impl.SessionImpl.fireSave(SessionImpl.java:563)
at org.hibernate.impl.SessionImpl.save(SessionImpl.java:551)
at org.hibernate.impl.SessionImpl.save(SessionImpl.java:547)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.hibernate.context.ThreadLocalSessionContext$TransactionProtectionWrapper.invoke(ThreadLocalSessionContext.java:342)
at $Proxy9.save(Unknown Source)
at com.hibernate.OnetoOneMapping.TestPerson.main(TestPerson.java:35)
Caused by: java.sql.SQLException: General error, message from server: "Table 'testdb.persondetail' doesn't exist"
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:1905)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1109)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1203)
at com.mysql.jdbc.Connection.execSQL(Connection.java:2090)
at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1680)
at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1527)
at org.hibernate.id.IdentityGenerator$GetGeneratedKeysDelegate.executeAndExtract(IdentityGenerator.java:94)
at org.hibernate.id.insert.AbstractReturningDelegate.performInsert(AbstractReturningDelegate.java:57)
... 37 more


here are my three class files



second file

3rd file


 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic