openjpa-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Kevin Sutter <kwsut...@gmail.com>
Subject Re: Help with Cassandra JPA plugin
Date Wed, 09 Mar 2011 14:42:21 GMT
Hi Todd,
Comments below...

On Tue, Mar 8, 2011 at 5:43 PM, Todd Nine <todd@spidertracks.com> wrote:

>
> Allocate doesn't appear to do anything in your test custom sequence
> either.  Is there any way to get the Open JPA framework to invoke it without
> allocating during the "next" call?
>
> https://fisheye6.atlassian.com/browse/~br=trunk/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/generationtype/CustomSeq.java?r=777135&r=757278
>
>
Allocate is used for allocating a block of sequences.  I believe we only use
this with some databases that could support this functionality.  I don't
believe we use allocate() when dealing with custom generators like what you
are trying to use.


>
> As per this example
>
> https://fisheye6.atlassian.com/browse/~br=trunk/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/generationtype/GeneratedValues.java?r=777135
>
> We're doing the same thing.  Is it possible to register the sequence
> generator we create globally with the Open JPA framework so that users can
> simply use the annotations like this without the need to declare a
> @SequenceGenerator?
>

Sure, you could, but it would be quite a bit of work...  :-)  Anything's
possible with enough coding.  But, the OpenJPA architecture does not allow
an easy to define plugin for this effort.  One thing you might want to
consider is to define your Generator in orm.xml and then just reference it
via your annotations.  That might be cleaner for your application.


>
> @Id
> @GeneratedValue(strategy="time-uuid")
> private UUID id;
>

Kevin


>
>
> On Tue, 2011-03-08 at 17:21 -0600, Kevin Sutter wrote:
>
> Hi Todd,
> Okay, now I understand your question.  I should read more closely...  :-)
>
> Looking at your code, nothing is jumping out at me as being incorrect.  You
> have implemented the Seq interface, and it looks like you have designated
> the sequenceName correctly.  We have a junit test case that does something
> very similar.  This test is also testing out UUID generation, so that might
> be of interest as well.
>
> Check this out for an example:
>
> https://fisheye6.atlassian.com/browse/~br=trunk/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/generationtype/TestGeneratedValues.java?hb=true
>
>
> https://fisheye6.atlassian.com/browse/~br=trunk/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/generationtype/GeneratedValues.java?r=777135
>
>
> https://fisheye6.atlassian.com/browse/~br=trunk/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/generationtype/CustomSeq.java?r=777135&r=757278
>
> Also, our UUID generation does lock and synchronize to protect certain code
> paths.  You'll probably need to do something similar.  Here's an example of
> our code:
>
> https://fisheye6.atlassian.com/browse/~br=trunk/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/util/UUIDGenerator.java?r=777135&r=757278&r=792592
>
> Good luck,
> Kevin
>
>  On Tue, Mar 8, 2011 at 2:46 PM, Todd Nine <todd@spidertracks.com> wrote:
>
>  Hey Kevin,
>   Thanks for the reply.  To be clear, I'm not actually creating a JDO
> plugin.  Rather I'm migrating what I've done from JDO to JPA.  The demand
> for JPA is much greater in the community, and we would prefer to use it here
> as well.   My biggest hurdle is finding good developer documentation to
> allow me to create the best plugin possible using open JPA.  If you can give
> me any guidance on the issues below for a JPA only implementation, I would
> really appreciate it.
>
> Thanks,
>
> Todd
>
>
>
>
>
>
>   On Tue, 2011-03-08 at 13:58 -0600, Kevin Sutter wrote:
>
> Some general comments...  Extending the OpenJPA kernel for JDO is
> definitely doable.  The original code base (BEA's Kodo) had a JDO
> personality, but it was never contributed to the OpenJPA project.  At least
> for a period of time (I don't know if it still is), BEA and then Oracle
> continued to support this JDO personality internally.  So, I know it's a
> doable endeavor...
>
> The other bit of news is that our own Craig Russell is a bit of JDO
> expert...  :-)  And, he might even know a thing or two about the JDO
> personality.
>
> Good luck,
> Kevin
>
> On Mon, Mar 7, 2011 at 10:22 PM, Todd Nine <todd@spidertracks.com> wrote:
>
> Hi guys,
>  I've previously developed a JDO plugin for Cassandra using
> Datanucleus.  I'm now helping the datastax guys develop the JPA plugin
> using open JPA.  I'm having some trouble I would use a hand with from
> developers.
>
> Current version 2.1.0
>
>
> Issue 1:  Defining an identity generator at the plugin level.
>
>
> Most of our users will want a TimeUUID generated as the default entity
> Id.  We do not want to do this as a string, but rather want to use the
> actual UUID object.  As you can see from my code here, I'm defining the
> generator at the entity level.  Since this will be a default use case
> for a lot of our users, I want to make it a standard part of our plugin.
>
>
> https://github.com/riptano/hector-jpa/blob/master/src/test/java/com/datastax/hectorjpa/bean/TimeUuidEntity.java
>
> and
>
>
> https://github.com/riptano/hector-jpa/blob/master/src/main/java/com/datastax/hectorjpa/sequence/TimeUuid.java
>
>
>
> Issue 2:  Allocate is never invoked on my sequence generator, I'm
> assuming this is due to incorrect setup that will be resolved in issue
> 1.
>
>
> Issue 3: Do I need to synchronize the next call internally in my
> Sequence generator?  Given the high throughput of our JPA clients, I
> don't want to accidentally return the same UUID to multiple callers.
>
>
> Thanks,
>
>
>
> --
> todd
> SENIOR SOFTWARE ENGINEER
>
> todd nine| spidertracks ltd |  117a the square
> po box 5203 | palmerston north 4441 | new zealand
> P: +64 6 353 3395
> E: todd@spidertracks.co.nz W: www.spidertracks.com
>
>
>
>
>
>
>
>
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message