openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Kevin Sutter <kwsut...@gmail.com>
Subject Re: Postgres sequence: current transaction is aborted
Date Mon, 18 Jun 2012 13:28:05 GMT
Hi Marco,
That 25P02 state from Postgres is so nebulous...  It really doesn't help
explain the problem that Postgres is complaining about...  We've had some
recent activity on the OpenJPA mailing lists related to Postgres and
Sequences.  It seems that we have varying degrees of success with different
customers.

Can you post the complete stack when you receive this error?  Have you
searched the log for other problems leading up to this Error?  Have you
tried turning on Trace for both OpenJPA and Postgres?  No guarantees, but
Trace might shed some light on the issue.

The Junit bucket for OpenJPA has various tests relating to Id generation
and sequences, and these seem to work with Postgres...  So, we might need
some assistance with narrowing in the test and debug setup to help
reproduce the problem and eventually solve it.

Thanks,
Kevin

On Sun, Jun 17, 2012 at 10:17 AM, Marco de Booij <mdebooy@scarlet.be> wrote:

> 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
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message