[Résolu][Hibernate] Rollback Exception improbable

Rollback Exception improbable [Résolu][Hibernate] - Java - Programmation

Marsh Posté le 08-07-2009 à 09:56:57    

Bonjour à tous,
 
je me tourne vers car comme à chaque fois vous me semblez être la solution de dernier. J'ai beau retourner le problème dans tous les sens et demander à tous le monde, nos compétences ne sont pas suffisantes. Alors voilà la bête :
 
J'ai une belle RollbackException qui est levée lorsque le programme tente un update sur une table. En voici la trace :

Code :
  1. javax.persistence.RollbackException: Error while commiting the transaction
  2.         at org.hibernate.ejb.TransactionImpl.commit(TransactionImpl.java:71)
  3.         at com.sfr.rprm.services.impl.AccountingVoucherImpl.updateProformaGenerationStep(AccountingVoucherImpl.java:156)
  4.         at $AccountingVoucherServices_12255d911b3.updateProformaGenerationStep($AccountingVoucherServices_12255d911b3.java)
  5.         at $AccountingVoucherServices_12255d911b1.updateProformaGenerationStep($AccountingVoucherServices_12255d911b1.java)
  6.         ...
  7. Caused by: java.lang.ClassCastException: com.sfr.rprm.persistence.Party
  8.         at org.hibernate.type.StringType.toString(StringType.java:44)
  9.         at org.hibernate.type.NullableType.toLoggableString(NullableType.java:218)
  10.         ...
  11.         at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:106)
  12.         at org.hibernate.ejb.TransactionImpl.commit(TransactionImpl.java:54)


Les select quant à eux fonctionnent très bien, et le truc marrant c'est que cette erreur je ne l'ai que sur certains environnement, sur d'autres le programme marche à merveille. Du coup j'irais bien regarder du côté des configs hibernate et/ou oracle mais je ne sais pas par quel bout commencer ...
 
Cette différence de comportement entre les environnements ainsi que les moultes vérifications notamment au niveau du mapping me font penser que le code est bon, mais au cas où, le voici :

Code :
  1. public class AccountingVoucherImpl
  2. extends AbstractService
  3. implements AccountingVoucherServices {
  4.   public AccountingVoucherImpl() {
  5. super();
  6.   }
  7.   public List<AccountingVoucher> findAllAccountingVouchers() {
  8. final List<AccountingVoucher> accountingVoucher =
  9.  getEM().createNamedQuery(AccountingVoucher.FIND_ALL).getResultList();
  10. if (accountingVoucher.size() > 0) {
  11.  return accountingVoucher;
  12. } else {
  13.  return null;
  14. }
  15.   }
  16.   public int updateProformaGenerationStep(Integer id, Long value) {
  17. getEM().getTransaction().begin();
  18. int i=(getEM().createNamedQuery(AccountingVoucher.PROFORMA_GENERATION_STEP)
  19.   .setParameter("id", id)
  20.   .setParameter("proformaGenerationStepValue", value)
  21.   .executeUpdate());
  22. getEM().getTransaction().commit();
  23. return i;
  24.   }
  25. }
Code :
  1. @Entity
  2. @Table(name = "ST_ACCOUNTING_VOUCHER" )
  3. @NamedQueries({
  4.   @NamedQuery(name = "AccountingVoucher.findAll", query = "SELECT a FROM AccountingVoucher a" ),
  5.   @NamedQuery(name = "AccountingVoucher.updateProformaGenerationStep",
  6. query = "UPDATE AccountingVoucher a SET a.proformaGenerationStep = :proformaGenerationStepValue WHERE a.id = :id"
  7.   )
  8. })
  9. public class AccountingVoucher {
  10.   public static String FIND_ALL = "AccountingVoucher.findAll";
  11.   public static String PROFORMA_GENERATION_STEP = "AccountingVoucher.updateProformaGenerationStep";
  12.   @Id
  13.   @Basic(optional = false)
  14.   @Column(name = "ACCOUNTING_VOUCHER_ID" )
  15.   private Integer id;
  16.   @ManyToOne
  17.   @JoinColumn(name="VENDOR_ID" )
  18.   private Party vendor;
  19.    
  20.   @ManyToOne
  21.   @JoinColumn(name="BUYER_ID" )
  22.   private Party buyer;
  23.   @Column(name = "PROFORMA_GENERATION_STEP" )
  24.   private Long proformaGenerationStep;
  25. }
Code :
  1. @Entity
  2. public class Party implements Serializable {
  3.   @ManyToOne
  4.   @JoinColumn(name="BUYER_ID" )
  5.   private Party buyer;
  6.   @Id
  7.   @Column(name="PARTY_ID", nullable = false)
  8.   private String partyId;
  9.    
  10.   @ManyToOne
  11.   @JoinColumn(name="VENDOR_ID" )
  12.   private Party vendor;
  13. }


D'avance merci à tous pour quelque participation que ce soit !


Message édité par HannibAlBundy le 09-07-2009 à 11:49:30
Reply

Marsh Posté le 08-07-2009 à 09:56:57   

Reply

Marsh Posté le 09-07-2009 à 11:48:51    

Problème résolu, il s'agissait en réalité d'un bug Hibernate lié au niveau de log debug. Il ne faut en fait pas descendre en dessous du niveau info.
 
http://opensource.atlassian.com/proj...rowse/HHH-2052

Reply

Sujets relatifs:

Leave a Replay

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