1. Hibernate Map Collection Map properties, CREATE TABLE failed or table does not exist

Source: Internet
Author: User

August 22, 2014 8:02:39 org.hibernate.annotations.common.Version <clinit>
INFO:HCANN000001:Hibernate Commons Annotations {4.0.2.Final}
August 22, 2014 8:02:39 pm org.hibernate.Version logversion
INFO:HHH000412:Hibernate Core {4.2.15.Final}
August 22, 2014 8:02:39 org.hibernate.cfg.Environment <clinit>
INFO:HHH000206:hibernate.properties not found
August 22, 2014 8:02:39 pm org.hibernate.cfg.Environment Buildbytecodeprovider
INFO:HHH000021:Bytecode provider Name:javassist
August 22, 2014 8:02:39 pm org.hibernate.cfg.Configuration Configure
INFO:HHH000043:Configuring from resource:/hibernate.cfg.xml
August 22, 2014 8:02:39 pm org.hibernate.cfg.Configuration getconfigurationinputstream
INFO:HHH000040:Configuration resource:/hibernate.cfg.xml
August 22, 2014 8:02:39 pm org.hibernate.internal.util.xml.DTDEntityResolver resolveentity
WARN:HHH000223:Recognized obsolete Hibernate namespace http://hibernate.sourceforge.net/. Use namespace Http://www.hibernate.org/dtd/instead. Refer to Hibernate 3.6 migration guide!
August 22, 2014 8:02:39 pm org.hibernate.cfg.Configuration AddResource
INFO:HHH000221:Reading mappings from Resource:org/crazyit/app/domain/person.hbm.xml
August 22, 2014 8:02:39 pm org.hibernate.cfg.Configuration doconfigure
INFO:HHH000041:Configured Sessionfactory:null
August 22, 2014 8:02:39 pm Org.hibernate.service.jdbc.connections.internal.DriverManagerConnectionProviderImpl Configure
WARN:HHH000402:Using Hibernate built-in connection pool (not for production use!)
August 22, 2014 8:02:39 pm Org.hibernate.service.jdbc.connections.internal.DriverManagerConnectionProviderImpl Configure
INFO:HHH000115:Hibernate Connection Pool size:20
August 22, 2014 8:02:39 pm Org.hibernate.service.jdbc.connections.internal.DriverManagerConnectionProviderImpl Configure
INFO:HHH000006:Autocommit Mode:false
August 22, 2014 8:02:39 pm Org.hibernate.service.jdbc.connections.internal.DriverManagerConnectionProviderImpl Configure
INFO:HHH000401:using driver [com.mysql.jdbc.Driver] at URL [Jdbc:mysql://localhost/hibernate]
August 22, 2014 8:02:39 pm Org.hibernate.service.jdbc.connections.internal.DriverManagerConnectionProviderImpl Configure
INFO:HHH000046:Connection Properties: {user=root, password=****}
August 22, 2014 8:02:39 org.hibernate.dialect.Dialect <init>
INFO:HHH000400:Using Dialect:org.hibernate.dialect.MySQLDialect
August 22, 2014 8:02:39 pm Org.hibernate.engine.jdbc.internal.LobCreatorBuilder usecontextuallobcreation
INFO:HHH000423:Disabling contextual LOB creation as JDBC driver reported JDBC version [3] less than 4
August 22, 2014 8:02:39 pm Org.hibernate.engine.transaction.internal.TransactionFactoryInitiator initiateservice
INFO:HHH000399:Using Default transaction strategy (direct JDBC transactions)
August 22, 2014 8:02:39 org.hibernate.hql.internal.ast.ASTQueryTranslatorFactory <init>
INFO:HHH000397:Using astquerytranslatorfactory
August 22, 2014 8:02:40 pm org.hibernate.tool.hbm2ddl.SchemaUpdate Execute
INFO:HHH000228:Running HBM2DDL Schema update
August 22, 2014 8:02:40 pm org.hibernate.tool.hbm2ddl.SchemaUpdate Execute
INFO:HHH000102:Fetching Database Metadata
August 22, 2014 8:02:40 pm org.hibernate.tool.hbm2ddl.SchemaUpdate Execute
INFO:HHH000396:Updating Schema
August 22, 2014 8:02:40 pm org.hibernate.tool.hbm2ddl.DatabaseMetadata gettablemetadata
INFO:HHH000262:Table not Found:person_inf
August 22, 2014 8:02:40 pm org.hibernate.tool.hbm2ddl.DatabaseMetadata gettablemetadata
INFO:HHH000262:Table not Found:score
August 22, 2014 8:02:40 pm org.hibernate.tool.hbm2ddl.DatabaseMetadata gettablemetadata
INFO:HHH000262:Table not Found:person_inf
August 22, 2014 8:02:40 pm org.hibernate.tool.hbm2ddl.DatabaseMetadata gettablemetadata
INFO:HHH000262:Table not Found:score
August 22, 2014 8:02:40 pm org.hibernate.tool.hbm2ddl.DatabaseMetadata gettablemetadata
INFO:HHH000262:Table not Found:person_inf
August 22, 2014 8:02:40 pm org.hibernate.tool.hbm2ddl.DatabaseMetadata gettablemetadata
INFO:HHH000262:Table not Found:score
August 22, 2014 8:02:40 pm org.hibernate.tool.hbm2ddl.SchemaUpdate Execute
ERROR:HHH000388:Unsuccessful:create Table score (person_id integer NOT null, grade float, subject varchar (255) not NULL, PRIMARY KEY (person_id, subject))
August 22, 2014 8:02:40 pm org.hibernate.tool.hbm2ddl.SchemaUpdate Execute
error:specified Key was too long; Max key length is 767 bytes
August 22, 2014 8:02:40 pm org.hibernate.tool.hbm2ddl.SchemaUpdate Execute
ERROR:HHH000388:Unsuccessful:alter Table score Add index Fk_337iubgcdgwrfqpvg418dt5u5 (person_id), add constraint F K_337iubgcdgwrfqpvg418dt5u5 foreign KEY (person_id) references Person_inf (person_id)
August 22, 2014 8:02:40 pm org.hibernate.tool.hbm2ddl.SchemaUpdate Execute
error:table ' hibernate.score ' doesn ' t exist
August 22, 2014 8:02:40 pm org.hibernate.tool.hbm2ddl.SchemaUpdate Execute
INFO:HHH000232:Schema Update complete
Hibernate:insert to Person_inf (name, age) VALUES (?,?)
Hibernate:insert into score (person_id, subject, Grade) VALUES (?,?,?)
August 22, 2014 8:02:40 pm org.hibernate.engine.jdbc.spi.SqlExceptionHelper logexceptions
warn:sql error:1146, Sqlstate:42s02
August 22, 2014 8:02:40 pm org.hibernate.engine.jdbc.spi.SqlExceptionHelper logexceptions
error:table ' hibernate.score ' doesn ' t exist
August 22, 2014 8:02:40 pm Org.hibernate.engine.jdbc.batch.internal.AbstractBatchImpl Release
INFO:HHH000010:On release of batch It still contained JDBC statements
Exception in thread ' main ' org.hibernate.exception.SQLGrammarException:could not execute statement
At Org.hibernate.exception.internal.SQLExceptionTypeDelegate.convert (sqlexceptiontypedelegate.java:82)
At Org.hibernate.exception.internal.StandardSQLExceptionConverter.convert ( standardsqlexceptionconverter.java:49)
At Org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert (sqlexceptionhelper.java:124)
At Org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert (sqlexceptionhelper.java:109)
At org.hibernate.engine.jdbc.internal.ResultSetReturnImpl.executeUpdate (resultsetreturnimpl.java:189)
At Org.hibernate.engine.jdbc.batch.internal.NonBatchingBatch.addToBatch (nonbatchingbatch.java:59)
At Org.hibernate.persister.collection.AbstractCollectionPersister.recreate (Abstractcollectionpersister.java : 1256)
At Org.hibernate.action.internal.CollectionRecreateAction.execute (collectionrecreateaction.java:58)
At Org.hibernate.engine.spi.ActionQueue.execute (actionqueue.java:395)
At org.hibernate.engine.spi.ActionQueue.executeActions (actionqueue.java:387)
At org.hibernate.engine.spi.ActionQueue.executeActions (actionqueue.java:309)
At Org.hibernate.event.internal.AbstractFlushingEventListener.performExecutions ( abstractflushingeventlistener.java:349)
At Org.hibernate.event.internal.DefaultFlushEventListener.onFlush (defaultflusheventlistener.java:56)
At Org.hibernate.internal.SessionImpl.flush (sessionimpl.java:1159)
At Org.hibernate.internal.SessionImpl.managedFlush (sessionimpl.java:404)
At Org.hibernate.engine.transaction.internal.jdbc.JdbcTransaction.beforeTransactionCommit ( JDBCTRANSACTION.JAVA:101)
At Org.hibernate.engine.transaction.spi.AbstractTransactionImpl.commit (abstracttransactionimpl.java:175)
At Lee. Personmanager.createandstoreperson (personmanager.java:43)
At Lee. Personmanager.main (personmanager.java:21)
caused by:com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException:Table ' hibernate.score ' doesn ' t exist
At Sun.reflect.NativeConstructorAccessorImpl.newInstance0 (Native Method)
At sun.reflect.NativeConstructorAccessorImpl.newInstance (nativeconstructoraccessorimpl.java:57)
At sun.reflect.DelegatingConstructorAccessorImpl.newInstance (delegatingconstructoraccessorimpl.java:45)
At java.lang.reflect.Constructor.newInstance (constructor.java:526)
At com.mysql.jdbc.Util.handleNewInstance (util.java:406)
At com.mysql.jdbc.Util.getInstance (util.java:381)
At com.mysql.jdbc.SQLError.createSQLException (sqlerror.java:1030)
At com.mysql.jdbc.SQLError.createSQLException (sqlerror.java:956)
At Com.mysql.jdbc.MysqlIO.checkErrorPacket (mysqlio.java:3515)
At Com.mysql.jdbc.MysqlIO.checkErrorPacket (mysqlio.java:3447)
At Com.mysql.jdbc.MysqlIO.sendCommand (mysqlio.java:1951)
At Com.mysql.jdbc.MysqlIO.sqlQueryDirect (mysqlio.java:2101)
At Com.mysql.jdbc.ConnectionImpl.execSQL (connectionimpl.java:2554)
At com.mysql.jdbc.PreparedStatement.executeInternal (preparedstatement.java:1761)
At com.mysql.jdbc.PreparedStatement.executeUpdate (preparedstatement.java:2046)
At com.mysql.jdbc.PreparedStatement.executeUpdate (preparedstatement.java:1964)
At com.mysql.jdbc.PreparedStatement.executeUpdate (preparedstatement.java:1949)
At org.hibernate.engine.jdbc.internal.ResultSetReturnImpl.executeUpdate (resultsetreturnimpl.java:186)
... more

L Reason: The primary key (person_id, subject) is used as the primary key when creating the table, and the Subject field is too long for the master key, so the table cannot be created.

L Workaround: Modify the length of the field to make the field smaller.

1.Hibernate Map Collection mapping properties, creating table failed or table not present

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.