openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Patrick Linskey" <plins...@gmail.com>
Subject Re: DBDictionary for SQLite
Date Mon, 29 Oct 2007 23:15:18 GMT
> Ok great, in that case I have no preference for @DataStoreId vs
> @GeneratedValue, I'll stick with the generated value, since it's JPA
> standard.

Gotcha -- I thought that you were saying that you preferred not using
the annotation for other reasons.

FYI, to assess compliance, I'd suggest creating a new maven test
profile for SQLite (copy-and-paste in either the top-level pom.xml or
in the openjpa-persistence-jdbc/pom.xml file), and running with that
profile to see what happens.

> Thanks for your help and for the great library.

You're welcome!

> Is there a company funding this work now?

The original source code contribution came from BEA, and BEA is
actively involved in OpenJPA (I'm a BEA employee, for example). There
are other folks employed by other organizations involved in the
project to varying degrees as well; I'll leave it to them to declare
themselves so that I don't forget anyone and feel bad about it.

But if you're looking for somewhere to send some beer to or something,
I'm sure you won't get any objections, of course.

-Patrick

On 10/29/07, Marc Siegel <marc.siegel.17@gmail.com> wrote:
> Oh!
>
> Ok great, in that case I have no preference for @DataStoreId vs
> @GeneratedValue, I'll stick with the generated value, since it's JPA
> standard.
>
> Thanks for your help and for the great library. Is there a company
> funding this work now?
>
> -Marc
>
>
> On 10/29/07, Patrick Linskey <plinskey@gmail.com> wrote:
> > Correct.
> >
> > -Patrick
> >
> > On 10/29/07, Marc Siegel <marc.siegel.17@gmail.com> wrote:
> > > Hi Patrick,
> > >
> > > Do I understand you to mean that I would see the same behavior were I
> > > running on top of MySql, in other words this is not SQLiteJDBC
> > > specific?
> > >
> > > -Marc
> > >
> > > On 10/29/07, Patrick Linskey <plinskey@gmail.com> wrote:
> > > > > > By "JPA auto strategy", I'm assuming that you mean @GeneratedValue
> > > > > > with no specified strategy, which defaults to GenerationType.AUTO.
> > > > >
> > > > > I mean, if I do not provide "@GeneratedValue(strategy =
> > > > > GenerationType.IDENTITY)", then I get errors. I'd prefer not to
> > > > > specify an @GeneratedValue tag at all.
> > > >
> > > > Ah, I see. Per the spec, the implementation only generates values when
> > > > you request that via the @GeneratedValue tag. If @GeneratedValue is
> > > > absent, the implementation assumes that you plan to provide an ID
> > > > value on your own. That's why they're all 0 in your case -- 0 is the
> > > > Java default for numbers.
> > > >
> > > > You might want to take a look at the OpenJPA @DataStoreId class-level
> > > > annotation. If you use it, you don't need to list an ID field in your
> > > > object model at all, and OpenJPA will automatically assign a value.
> > > >
> > > > -Patrick
> > > >
> > > > On 10/29/07, Marc Siegel <marc.siegel.17@gmail.com> wrote:
> > > > > Hi Patrick,
> > > > >
> > > > > > By "JPA auto strategy", I'm assuming that you mean @GeneratedValue
> > > > > > with no specified strategy, which defaults to GenerationType.AUTO.
> > > > >
> > > > > I mean, if I do not provide "@GeneratedValue(strategy =
> > > > > GenerationType.IDENTITY)", then I get errors. I'd prefer not to
> > > > > specify an @GeneratedValue tag at all.
> > > > >
> > > > > > In OpenJPA, I believe that this translates to the same behavior
as
> > > > > > GenerationType.TABLE. What sorts of problems are you seeing
with this
> > > > > > strategy?
> > > > >
> > > > > Below please see a stack trace from trying to persist the 2nd of
two
> > > > > simple entities. They have 3 fields: (id INTEGER PRIMARY KEY, created
> > > > > TIMESTAMP, message TEXT).
> > > > >
> > > > > Again, I am trying to make OpenJPA work on top of SQLiteJDBC.
> > > > > These errors disappear if I add the GenerationType.IDENTITY to the
@Id column.
> > > > >
> > > > > Thanks for any help
> > > > > -Marc
> > > > >
> > > > >
> > > > > $ sh ./target/appassembler/bin/openjpa-testapp
> > > > > Exception in thread "main" <openjpa-1.0.0-r420667:568756 fatal
store
> > > > > error> org.apache.openjpa.persistence.RollbackException: The
> > > > > transaction has been rolled back.  See the nested exceptions for
> > > > > details on the errors that occurred.
> > > > >         at org.apache.openjpa.persistence.EntityManagerImpl.commit(EntityManagerImpl.java:419)
> > > > >         at com.leadgenllc.testapp.openjpa.OpenJPATestApp.main(OpenJPATestApp.java:50)
> > > > > Caused by: <openjpa-1.0.0-r420667:568756 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.
> > > > >         at org.apache.openjpa.kernel.BrokerImpl.newFlushException(BrokerImpl.java:2099)
> > > > >         at org.apache.openjpa.kernel.BrokerImpl.flush(BrokerImpl.java:1946)
> > > > >         at org.apache.openjpa.kernel.BrokerImpl.flushSafe(BrokerImpl.java:1844)
> > > > >         at org.apache.openjpa.kernel.BrokerImpl.beforeCompletion(BrokerImpl.java:1762)
> > > > >         at org.apache.openjpa.kernel.LocalManagedRuntime.commit(LocalManagedRuntime.java:81)
> > > > >         at org.apache.openjpa.kernel.BrokerImpl.commit(BrokerImpl.java:1292)
> > > > >         at org.apache.openjpa.kernel.DelegatingBroker.commit(DelegatingBroker.java:861)
> > > > >         at org.apache.openjpa.persistence.EntityManagerImpl.commit(EntityManagerImpl.java:408)
> > > > >         ... 1 more
> > > > > Caused by: <openjpa-1.0.0-r420667:568756 nonfatal general error>
> > > > > org.apache.openjpa.persistence.PersistenceException: PRIMARY KEY
must
> > > > > be unique {prepstmnt 3524528 INSERT INTO Message (id, created,
> > > > > message) VALUES (?, ?, ?) [params=(long) 0, (Timestamp) 2007-10-29
> > > > > 15:42:53.46, (String) Number Two!]} [code=0, state=null]
> > > > > FailedObject: com.leadgenllc.testapp.openjpa.Message@eee615
> > > > >         at org.apache.openjpa.jdbc.sql.DBDictionary.newStoreException(DBDictionary.java:3849)
> > > > >         at org.apache.openjpa.jdbc.sql.SQLExceptions.getStore(SQLExceptions.java:97)
> > > > >         at org.apache.openjpa.jdbc.sql.SQLExceptions.getStore(SQLExceptions.java:67)
> > > > >         at org.apache.openjpa.jdbc.kernel.PreparedStatementManagerImpl.flushInternal(PreparedStatementManagerImpl.java:108)
> > > > >         at org.apache.openjpa.jdbc.kernel.PreparedStatementManagerImpl.flush(PreparedStatementManagerImpl.java:73)
> > > > >         at org.apache.openjpa.jdbc.kernel.ConstraintUpdateManager.flush(ConstraintUpdateManager.java:543)
> > > > >         at org.apache.openjpa.jdbc.kernel.ConstraintUpdateManager.flush(ConstraintUpdateManager.java:105)
> > > > >         at org.apache.openjpa.jdbc.kernel.AbstractUpdateManager.flush(AbstractUpdateManager.java:89)
> > > > >         at org.apache.openjpa.jdbc.kernel.AbstractUpdateManager.flush(AbstractUpdateManager.java:72)
> > > > >         at org.apache.openjpa.jdbc.kernel.JDBCStoreManager.flush(JDBCStoreManager.java:514)
> > > > >         at org.apache.openjpa.kernel.DelegatingStoreManager.flush(DelegatingStoreManager.java:130)
> > > > >         ... 8 more
> > > > > Caused by: org.apache.openjpa.lib.jdbc.ReportingSQLException: PRIMARY
> > > > > KEY must be unique {prepstmnt 3524528 INSERT INTO Message (id,
> > > > > created, message) VALUES (?, ?, ?) [params=(long) 0, (Timestamp)
> > > > > 2007-10-29 15:42:53.46, (String) Number Two!]} [code=0, state=null]
> > > > >         at org.apache.openjpa.lib.jdbc.LoggingConnectionDecorator.wrap(LoggingConnectionDecorator.java:192)
> > > > >         at org.apache.openjpa.lib.jdbc.LoggingConnectionDecorator.access$800(LoggingConnectionDecorator.java:57)
> > > > >         at org.apache.openjpa.lib.jdbc.LoggingConnectionDecorator$LoggingConnection$LoggingPreparedStatement.executeUpdate(LoggingConnectionDecorator.java:858)
> > > > >         at org.apache.openjpa.lib.jdbc.DelegatingPreparedStatement.executeUpdate(DelegatingPreparedStatement.java:269)
> > > > >         at org.apache.openjpa.jdbc.kernel.JDBCStoreManager$CancelPreparedStatement.executeUpdate(JDBCStoreManager.java:1363)
> > > > >         at org.apache.openjpa.jdbc.kernel.PreparedStatementManagerImpl.flushInternal(PreparedStatementManagerImpl.java:97)
> > > > >         ... 15 more
> > > > > marc-siegels-computer:~/belvedere/maven/joe-testapp mlsiegel$
> > > > >
> > > > > On 10/29/07, Patrick Linskey <plinskey@gmail.com> wrote:
> > > > > > Hi,
> > > > > >
> > > > > > By "JPA auto strategy", I'm assuming that you mean @GeneratedValue
> > > > > > with no specified strategy, which defaults to GenerationType.AUTO.
> > > > > >
> > > > > > In OpenJPA, I believe that this translates to the same behavior
as
> > > > > > GenerationType.TABLE. What sorts of problems are you seeing
with this
> > > > > > strategy?
> > > > > >
> > > > > > -Patrick
> > > > > >
> > > > > > On 10/29/07, Marc Siegel <marc.siegel.17@gmail.com> wrote:
> > > > > > > Since I posted that mail, I looked through the source code
of
> > > > > > > DBDictionary, and as a result of that I the SQLiteDictionary
to have
> > > > > > >    lastGeneratedKeyQuery = "SELECT MAX({0}) FROM {1}";
> > > > > > >
> > > > > > > My mapping is simply any class with an @Id column. I have
succeeded in
> > > > > > > making this work by adding @GeneratedValue(strategy =
> > > > > > > GenerationType.IDENTITY), but would like to be able to
make this work
> > > > > > > with the JPA auto strategy as well.
> > > > > > >
> > > > > > > Thanks
> > > > > > > -Marc
> > > > > > >
> > > > > > > On 10/28/07, Patrick Linskey <plinskey@gmail.com>
wrote:
> > > > > > > > Hi,
> > > > > > > >
> > > > > > > > What does your mapping look like for your class?
> > > > > > > >
> > > > > > > > -Patrick
> > > > > > > >
> > > > > > > > On 10/26/07, Marc Siegel <marc.siegel.17@gmail.com>
wrote:
> > > > > > > > > Hi folks,
> > > > > > > > >
> > > > > > > > > I am trying to user OpenJPA 1.0.0 on top of SQLiteJDBC.
> > > > > > > > > OpenJPA wants to insert an Id if zero for every
row.
> > > > > > > > >
> > > > > > > > > I know I need a DBDictionary subclass, I have
tried making one with
> > > > > > > > >   - createPrimaryKey = false
> > > > > > > > >   -  lastGeneratedKeyQuery = "SELECT SEQ FROM
SQLITE_SEQUENCE WHERE
> > > > > > > > > NAME = \"{0}\"";
> > > > > > > > >
> > > > > > > > > Neither of these worked. Any knowledgable suggestions?
> > > > > > > > >
> > > > > > > > > Many thanks,
> > > > > > > > > -Marc
> > > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > > > --
> > > > > > > > Patrick Linskey
> > > > > > > > 202 669 5907
> > > > > > > >
> > > > > > >
> > > > > >
> > > > > >
> > > > > > --
> > > > > > Patrick Linskey
> > > > > > 202 669 5907
> > > > > >
> > > > >
> > > >
> > > >
> > > > --
> > > > Patrick Linskey
> > > > 202 669 5907
> > > >
> > >
> >
> >
> > --
> > Patrick Linskey
> > 202 669 5907
> >
>


-- 
Patrick Linskey
202 669 5907

Mime
View raw message