You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@openjpa.apache.org by RudiWelter <ru...@hotmail.com> on 2010/09/30 11:31:17 UTC
openjpa 1.0.4 : primary key not created
Hello users,
due the circumstances I need to use openjpa 1.0.4.
I've an entity where the Id will be generated by a sequence. I create an new
instance of the entity and call entityManager.persist(instance).
I get next exception
org.springframework.orm.jpa.JpaSystemException: The transaction has been
rolled back. See the nested exceptions for details on the errors that
occurred.; nested exception is <openjpa-1.0.4-r420667:989711 fatal general
error> org.apache.openjpa.persistence.PersistenceException: The transaction
has been rolled back. See the nested exceptions for details on the errors
that occurred.
...
Caused by: <openjpa-1.0.4-r420667:989711 nonfatal general error>
org.apache.openjpa.persistence.PersistenceException: ORA-01400: cannot
insert NULL into ("FRM"."JOBDEF"."ID")
{prepstmnt 9592423 INSERT INTO JOBDEF (ACTIVE, CLASSNAME, JOBNAME,
JOBPARAMS) VALUES (?, ?, ?, ?) [params=?, ?, ?, ?]} [code=1400, state=23000]
So, for some reason, the ID is not created. I'm looking around but can't
find a solution.
Here is the entity with the ID
@Entity
@Table(name = "JOBDEF")
public class SequenceIdJobDefinitionImpl extends JobDefinitionBaseImpl {
/** The Constant serialVersionUID. */
private static final long serialVersionUID = 7851794269407495684L;
/** The id. */
@Id
@SequenceGenerator(name = "JOBDEF_SEQUENCE_GENERATOR", sequenceName =
"JOBDEF_SEQ")
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator =
"JOBDEF_SEQUENCE_GENERATOR")
private Long id;
/**
* Gets the id.
*
* @return the id
* @see
com.ing.rcc.be.hbexport.taskmgr.data.model.impl.JobDefinitionBaseImpl
* #getId()
*/
public Long getId() {
return id;
}
/**
* Sets the id.
*
* @param id
* the new id
*/
public void setId(Long id) {
this.id = id;
}
}
Any clues ?
many regards,
Rudi Welter
--
View this message in context: http://openjpa.208410.n2.nabble.com/openjpa-1-0-4-primary-key-not-created-tp5587124p5587124.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.
Re: openjpa 1.0.4 : primary key not created
Posted by Kevin Sutter <kw...@gmail.com>.
Hi Rudi,
Depending on your environment configuration, either use a
<non-jta-data-source> or the openjpa.Connection2* set of properties to
define your unmanaged datasource. This is documented in this area of the
documentation [1]. The reference is for 2.0.1, but you can find similar
documentation for 1.0.4.
Kevin
[1]
http://openjpa.apache.org/builds/2.0.1/apache-openjpa-2.0.1/docs/manual/manual.html#ref_guide_dbsetup_thirdparty_enlist
On Thu, Sep 30, 2010 at 6:36 AM, RudiWelter <ru...@hotmail.com> wrote:
>
> I already discovered that I should use an unmanaged datasource for things
> like database sequence handling. Because we use Spring, where the
> datasource
> is set in spring configuration files, how can I use an unmanaged datasource
> in persistence.xml refering to the Spring one ?
>
> if possible, please give an example.
>
> Rudi Welter
> --
> View this message in context:
> http://openjpa.208410.n2.nabble.com/openjpa-1-0-4-primary-key-not-created-tp5587124p5587420.html
> Sent from the OpenJPA Users mailing list archive at Nabble.com.
>
Re: openjpa 1.0.4 : primary key not created
Posted by RudiWelter <ru...@hotmail.com>.
I already discovered that I should use an unmanaged datasource for things
like database sequence handling. Because we use Spring, where the datasource
is set in spring configuration files, how can I use an unmanaged datasource
in persistence.xml refering to the Spring one ?
if possible, please give an example.
Rudi Welter
--
View this message in context: http://openjpa.208410.n2.nabble.com/openjpa-1-0-4-primary-key-not-created-tp5587124p5587420.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.