Vc ja verificou em quanto esta iniciado o sequenciador da tabela no Postgres?
Shemas --> public --> sequences(procure o sequenciador da tabela e
clique com o botão direito nela) --> Properties -->Aba Definition --> na
opção Current value caso não esteja altere para o valor atual do [b]id/b que esta na tabela.
Gente estou com um mapeamento @OneToOne unidirecional e esta mapeado tudo certinho. Só que no momento do Insert exibe este erro :
Caused by: java.sql.BatchUpdateException: Entrada em lote 0 insert into econtas.tbl_anexo_fundamento_legal (blob_anexo, cod_competencia, des_nome_arquivo, id_anexo_fundamento_legal) values ('<stream of 71126 bytes>', '201212', 'TUTORIAL CONTROLE DE VERSÃ?ES.PDF', '18') foi abortada. Chame getNextException para ver a causa.
at org.postgresql.jdbc2.AbstractJdbc2Statement$BatchResultHandler.handleError(AbstractJdbc2Statement.java:2621)
at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1837)
at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:407)
at org.postgresql.jdbc2.AbstractJdbc2Statement.executeBatch(AbstractJdbc2Statement.java:2754)
at com.mchange.v2.c3p0.impl.NewProxyPreparedStatement.executeBatch(NewProxyPreparedStatement.java:1723)
at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:70)
at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:268)
... 63 more
Pelo que vi os campos estão sendo passado todos certos…
AnexoFundamentoLegal anexoFundamentoLegal = new AnexoFundamentoLegal();
anexoFundamentoLegal.setBlobAnexo( file.getContents() );
anexoFundamentoLegal.setDesNomeArquivo( file.getFileName() );
anexoFundamentoLegal.setCodCompetencia( usuarioWeb.getUsuario().getCod_competencia() );
fundamentoLegal.setAnexoFundamentoLegal(anexoFundamentoLegal);
@SuppressWarnings("serial")
@Entity
@Table(name = "tbl_anexo_fundamento_legal", schema = "econtas")
@SequenceGenerator(name = "tbl_anexo_fundamento_legal_id_anexo_fundamento_legal_seq", sequenceName = "econtas.tbl_anexo_fundamento_legal_id_anexo_fundamento_legal_seq")
public class AnexoFundamentoLegal implements java.io.Serializable {
@OneToOne(fetch=FetchType.LAZY,cascade = CascadeType.ALL)
@JoinColumn(name="id_anexo_fundamento_legal")
public AnexoFundamentoLegal getAnexoFundamentoLegal() {
return this.anexoFundamentoLegal;
}
public void setAnexoFundamentoLegal(AnexoFundamentoLegal anexoFundamentoLegal) {
this.anexoFundamentoLegal = anexoFundamentoLegal;
}
}