[Hibernate] forcer le troncage des champs depassant les 255 chars.

forcer le troncage des champs depassant les 255 chars. [Hibernate] - Java - Programmation

Marsh Posté le 07-06-2007 à 12:41:17    

Bonjour,
Voila j'exporte vers oracle des champs dont la taille est helas libre du coté de la source et fixé à 255 coté oracle:

Code :
  1. <property name="text4" type="string">
  2.   <column name="TEXT4" length="255" />
  3.  </property>

 
Comment forcer Hibernate à couper le champs si celui ci depasse les 255 simplement en modifiant le fichier XML de mapping?
 
Voici l'exception:
 

Code :
  1. org.hibernate.exception.ConstraintViolationException: could not update: [com.sgcib.crs.it2.projcom.hibernate.TaskInfo#component[projectId,taskid]{projectId=12EM3L1, taskid=12EM420}]
  2. at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:71)
  3. at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
  4. at org.hibernate.persister.entity.AbstractEntityPersister.update(AbstractEntityPersister.java:2222)
  5. at org.hibernate.persister.entity.AbstractEntityPersister.updateOrInsert(AbstractEntityPersister.java:2118)
  6. at org.hibernate.persister.entity.AbstractEntityPersister.update(AbstractEntityPersister.java:2374)
  7. at org.hibernate.action.EntityUpdateAction.execute(EntityUpdateAction.java:91)
  8. at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:248)
  9. at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:232)
  10. at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:140)
  11. at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:297)
  12. at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
  13. at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:985)
  14. at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:333)
  15. at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:106)
  16. at com.sgcib.crs.it2.projcom.ExportProjects.exportProjects(ExportProjects.java:331)
  17. at com.sgcib.crs.it2.projcom.Main.main(Main.java:58)
  18. at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  19. at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
  20. at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
  21. at java.lang.reflect.Method.invoke(Method.java:585)
  22. at com.lebihan.startup.ConfigStarter.run(ConfigStarter.java:204)
  23. at com.lebihan.startup.Starter.main(Starter.java:42)
  24. Caused by: java.sql.BatchUpdateException: ORA-01401: inserted value too large for column

Reply

Marsh Posté le 07-06-2007 à 12:41:17   

Reply

Marsh Posté le 07-06-2007 à 14:41:17    

regarde du coté de org.hibernate.CompositeUserType
 
en implementant un type perso tu dois pouvoir couper quand c'est trop long

Reply

Sujets relatifs:

Leave a Replay

Make sure you enter the(*)required information where indicate.HTML code is not allowed