[jboss-user] [EJB 3.0] - How to map String[]

jc7442 do-not-reply at jboss.com
Tue Sep 26 08:22:02 EDT 2006


I have a String[] in a persistent entity. I've tried to add the @Lob annotation. Unfortunattly it does not works, I have the following exception:

  | Caused by: java.lang.ClassCastException: [Ljava.lang.String;
  | 	at org.hibernate.type.StringClobType.nullSafeSet(StringClobType.java:56)
  | 	at org.hibernate.type.CustomType.nullSafeSet(CustomType.java:145)
  | 	at org.hibernate.persister.entity.AbstractEntityPersister.dehydrate(AbstractEntityPersister.java:1910)
  | 	at org.hibernate.persister.entity.AbstractEntityPersister.dehydrate(AbstractEntityPersister.java:1887)
  | 	at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2117)
  | 	at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2503)
  | 	at org.hibernate.action.EntityInsertAction.execute(EntityInsertAction.java:51)
  | 	at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:248)
  | 	at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:232)
  | 	at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:139)
  | 	at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:297)
  | 	at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
  | 	at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:993)
  | 	at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:340)

The String[] is cast in String. Consequetly we have an exception. Moreover, array is stored in DB as CLOB (maybe a blob will be better).

I used oracle10g, Embedded EJB3 RC9.

Is it possible to map an String[] ?

I have tried with the Basic annotation. It works only if there is few String in the array. When I try to put 200 String in the array I have the exception:

Caused by: org.hibernate.exception.GenericJDBCException: Could not execute JDBC batch update
  | 	at org.hibernate.exception.SQLStateConverter.handledNonSpecificException(SQLStateConverter.java:103)
  | 	at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:91)
  | 	at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
  | 	at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:249)
  | 	at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:235)
  | 	at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:139)
  | 	at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:297)
  | 	at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
  | 	at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:993)
  | 	at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:340)
  | 	at org.hibernate.ejb.AbstractEntityManagerImpl$1.beforeCompletion(AbstractEntityManagerImpl.java:475)
  | 	... 20 more
  | Caused by: java.sql.BatchUpdateException: ORA-12899: valeur trop grande pour la colonne "ROOT"."TOTOPE"."SS" (réelle : 2134, maximum : 255)
  | 
  | 	at oracle.jdbc.driver.DatabaseError.throwBatchUpdateException(DatabaseError.java:498)
  | 	at oracle.jdbc.driver.OraclePreparedStatement.executeBatch(OraclePreparedStatement.java:12369)
  | 	at org.jboss.resource.adapter.jdbc.WrappedStatement.executeBatch(WrappedStatement.java:517)INFO  26-09 14:20:28,584 (Log4JLogger.java:info:94)  -closing
  | INFO  26-09 14:20:28,584 (Log4JLogger.java:info:94)  -Running hbm2ddl schema export
  | DEBUG 26-09 14:20:28,584 (Log4JLogger.java:debug:84)  -import file not found: /import.sql
  | INFO  26-09 14:20:28,584 (Log4JLogger.java:info:94)  -exporting generated schema to database
  | DEBUG 26-09 14:20:28,584 (Log4JLogger.java:debug:84)  -drop table Assay cascade constraints
  | 
  | 	at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:58)
  | 	at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:242)
  | 	... 27 more

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3974189#3974189

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3974189




More information about the jboss-user mailing list