openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Marco de Booij <mdeb...@scarlet.be>
Subject Postgres sequence: current transaction is aborted
Date Sun, 17 Jun 2012 15:17:38 GMT
Hello,

I have been searching on the internet for a solution of 'my' problem:
ERROR: current transaction is aborted, commands ignored until end of 
transaction block {prepstmnt 253501751 SELECT 
NEXTVAL('DOOS.SEQ_I18N_CODES')} [code=0, state=25P02]

I found questions on this dating back to 2000 but not clear answer (to 
me) on how to solve it.

What do I have? A class to persist:
@Entity
@Table(name="I18N_CODES", schema="DOOS")
@SequenceGenerator(name="SEQ_CODE_ID", schema="DOOS", 
sequenceName="SEQ_I18N_CODES")
public class I18nCodeDto extends Dto
     implements Comparable<I18nCodeDto>, Cloneable {
   @Id
   @GeneratedValue(strategy=GenerationType.SEQUENCE, 
generator="SEQ_CODE_ID")
   @Column(name="CODE_ID", nullable=false)
   private Long codeId;
   @Column(name="CODE", length=100, nullable=false, unique=true)
   private String  code;

   @OneToMany(fetch=FetchType.EAGER)
   @JoinColumn(name="CODE_ID")
   @OrderBy("id.taalKode ASC")
   private List<I18nCodeTekstDto>  teksten = new 
ArrayList<I18nCodeTekstDto>();

The class has the getters and setters that are needed. The user that 
connects to the datasource has access to the sequence and the tables. I 
get the error when I try to persist the object.
          i18nCodeComponent.insert(i18nCode);

The insert ends up in a create method:
   /**
    * Persist de DTO
    *
    * @param dto
    * @return
    * @throws DoosRuntimeException
    * @throws DuplicateObjectException
    */
   public T create(T dto) throws DoosRuntimeException, 
DuplicateObjectException {
     if (getEntityManager().contains(dto)) {
         throw new DuplicateObjectException(DoosLayer.PERSISTENCE, dto,
                                            "bestaat reeds");
     }

     getEntityManager().persist(dto);
     getEntityManager().flush();
     getEntityManager().refresh(dto);

     return dto;
   }

My question is how I solve this problem?

I tried it with Postgres 8.4 and 9.1 with the jdbc drivers for this 
version and it failed in both cases. The code worked fine when I used 
MySQL with auto-increment (with the correct @GeneratedValue :-) ) and 
with Oracle Sequence + Hibernate it also works.

I use apache-tomee-plus-1.0.0.

Regards,

Marco


Mime
View raw message