Problem field is pageText :(
PageText.length() < 2^16 always
Hibernate version:
3.2, JDK - 1.5.0_05, 1.6.0-rc
Mapping documents:
- Post.hmb.xml
<id name="postId" column="postId" type="long">
<generator class="native"/>
</id>
<property name="threadId" column="threadId" type="long"/>
<property name="forumId" column="forumId" type="long"/>
<property name="numberInThread" column="numberInThread" type="long"/>
<property name="title" column="title" type="string"/>
<property name="username" column="username" type="string"/>
<property name="pagetext" column="pagetext" type="text"/>
Code between sessionFactory.openSession() and session.close():
public class HibernateUtil {
private static final SessionFactory sessionFactory;
static {
try {
// Create the SessionFactory from hibernate.cfg.xml
sessionFactory = new Configuration().configure().buildSessionFactory();
} catch (Throwable ex) {
// Make sure you log the exception, as it might be swallowed
System.err.println("Initial SessionFactory creation failed." + ex);
throw new ExceptionInInitializerError(ex);
}
}
public static SessionFactory getSessionFactory() {
return sessionFactory;
}
}
Session session = HibernateUtil.getSessionFactory().getCurrentSession();
session.beginTransaction();
session.save(post);
session.getTransaction().commit();
Full stack trace of any exception that occurs:
Hibernate: insert into post (threadId, forumId, numberInThread, title, username, pagetext) values (?, ?, ?, ?, ?, ?)
06.12.2006 17:17:47 org.hibernate.util.JDBCExceptionReporter logExceptions
WARNING: SQL Error: 0, SQLState: 01004
06.12.2006 17:17:47 org.hibernate.util.JDBCExceptionReporter logExceptions
SEVERE: Data truncation: Data truncated for column 'pagetext' at row 1
Exception in thread "Thread-1" org.hibernate.exception.GenericJDBCException: could not insert: [ru.fg.parsers.ForumPost]
at org.hibernate.exception.SQLStateConverter.handledNonSpecificException
(SQLStateConverter.java:103)
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.j
ava:91)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelp
er.java:43)
at org.hibernate.id.insert.AbstractReturningDelegate.performInsert(Abstr
actReturningDelegate.java:40)
at org.hibernate.persister.entity.AbstractEntityPersister.insert(Abstrac
tEntityPersister.java:2108)
at org.hibernate.persister.entity.AbstractEntityPersister.insert(Abstrac
tEntityPersister.java:2588)
at org.hibernate.action.EntityIdentityInsertAction.execute(EntityIdentit
yInsertAction.java:48)
at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:248)
at org.hibernate.event.def.AbstractSaveEventListener.performSaveOrReplic
ate(AbstractSaveEventListener.java:290)
at org.hibernate.event.def.AbstractSaveEventListener.performSave(Abstrac
tSaveEventListener.java:180)
at org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId
(AbstractSaveEventListener.java:108)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.saveWithGene
ratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:186)
at org.hibernate.event.def.DefaultSaveEventListener.saveWithGeneratedOrR
equestedId(DefaultSaveEventListener.java:33)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsTran
sient(DefaultSaveOrUpdateEventListener.java:175)
at org.hibernate.event.def.DefaultSaveEventListener.performSaveOrUpdate(
DefaultSaveEventListener.java:27)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpda
te(DefaultSaveOrUpdateEventListener.java:70)
at org.hibernate.impl.SessionImpl.fireSave(SessionImpl.java:535)
at org.hibernate.impl.SessionImpl.save(SessionImpl.java:523)
at org.hibernate.impl.SessionImpl.save(SessionImpl.java:519)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.hibernate.context.ThreadLocalSessionContext$TransactionProtection
Wrapper.invoke(ThreadLocalSessionContext.java:301)
at $Proxy0.save(Unknown Source)
at ru.fg.DataController.insertPost(Unknown Source)
at ru.fg.net.ThreadsCoordinator.run(Unknown Source)
Caused by: com.mysql.jdbc.MysqlDataTruncation: Data truncation: Data truncated f
or column 'pagetext' at row 1
at com.mysql.jdbc.SQLError.convertShowWarningsToSQLWarnings(SQLError.jav
a:717)
at com.mysql.jdbc.MysqlIO.scanForAndThrowDataTruncation(MysqlIO.java:303
1)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1812)
at com.mysql.jdbc.Connection.execSQL(Connection.java:3170)
at com.mysql.jdbc.Connection.execSQL(Connection.java:3099)
at com.mysql.jdbc.Statement.executeQuery(Statement.java:1169)
at com.mysql.jdbc.SQLError.convertShowWarningsToSQLWarnings(SQLError.jav
a:710)
at com.mysql.jdbc.MysqlIO.scanForAndThrowDataTruncation(MysqlIO.java:303
1)
at com.mysql.jdbc.ServerPreparedStatement.serverExecute(ServerPreparedSt
atement.java:1250)
at com.mysql.jdbc.ServerPreparedStatement.executeInternal(ServerPrepared
Statement.java:693)
at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java
:1404)
at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java
:1318)
at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java
:1303)
at org.hibernate.id.IdentityGenerator$GetGeneratedKeysDelegate.executeAn
dExtract(IdentityGenerator.java:73)
at org.hibernate.id.insert.AbstractReturningDelegate.performInsert(Abstr
actReturningDelegate.java:33)
... 23 more
Name and version of the database you are using:
mysql-4.1.21-community-nt
The generated SQL (show_sql=true):
Hibernate: insert into post (threadId, forumId, numberInThread, title, username,
pagetext) values (?, ?, ?, ?, ?, ?)
Debug level Hibernate log excerpt:???
mysql.jdbc.connectors:
3.1.14
5.0.4
Last edited by vilia on Wed Dec 06, 2006 10:39 am, edited 1 time in total.
|