db-jdo-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Craig Russell <Craig.Russ...@Sun.COM>
Subject Re: jpox cannot find sequence
Date Sat, 17 Sep 2005 20:35:16 GMT
Javadogs,

Please review this patch. I've added a new implementation class for  
nontransactional sequence factory and a test class for it.

Andy, Erik,

Is it possible to use the SimpleSequenceFactory as a sequence factory  
with JPOX? It does adhere to the specified interface and static  
newInstance method.

Craig


On Sep 16, 2005, at 12:13 AM, Andy Jefferson wrote:

>> Can you help us define a table-based incrementing sequence that can
>> be used with the TCK? We (TCK team) will write a factory sequence
>> class but as you know, the specification is short on how to define  
>> it.
>>
>
> Hi Craig, Karan,
>
> JPOX provides some sequences internally, and also we have a sample  
> "factory"
> sequence in our unit tests. Here's an example
>
> <sequence name="ProductSequence" datastore-sequence="PRODUCT_SEQ"
> strategy="contiguous"/>
> Where the RDBMS supports sequences then JPOX will use the RDBMS  
> sequence of
> name "PRODUCT_SEQ". Where the RDBMS doesn't support sequences then  
> JPOX will
> utilise a table in the datastore (by default called SEQUENCE_TABLE)  
> and the
> table will have one row per sequence name, storing the sequence  
> name, and the
> current value.
>
>
> As for "factory" sequences, I interpret this as something a user  
> can provide
> to utilise their own (maybe corporate) way of generating sequences.  
> Clearly a
> JDO implementation could provide builtin "factory" sequences, but JPOX
> doesn't right now. An incredibly simple example of a "factory" that  
> we use in
> our unit tests is a sequence that just does counting - not intended  
> for use
> in real world apps, just a test of the factory class process
>
> public class SimpleSequenceFactory
> {
>     public static Sequence newInstance()
>     {
>         return new SimpleSequence("My Sequence");
>     }
> }
>
> public class SimpleSequence implements Sequence
> {
>     String name;
>     long current = 0;
>
>     public SimpleSequence(String name)
>     {
>         this.name = name;
>     }
>
>     /**
>      *
>      * @see javax.jdo.datastore.Sequence#getName()
>      */
>     public String getName()
>     {
>         return name;
>     }
>
>     /**
>      *
>      * @see javax.jdo.datastore.Sequence#next()
>      */
>     public Object next()
>     {
>         current++;
>         return new Long(current);
>     }
>
>     /**
>      *
>      * @see javax.jdo.datastore.Sequence#nextValue()
>      */
>     public long nextValue()
>     {
>         current++;
>         return current;
>     }
>
>     /**
>      *
>      * @see javax.jdo.datastore.Sequence#allocate(int)
>      */
>     public void allocate(int arg0)
>     {
>     }
>
>     /**
>      *
>      * @see javax.jdo.datastore.Sequence#current()
>      */
>     public Object current()
>     {
>         return new Long(current);
>     }
>
>     /**
>      *
>      * @see javax.jdo.datastore.Sequence#currentValue()
>      */
>     public long currentValue()
>     {
>         return current;
>     }
> }
>
>
> If the TCK wants to define its own factory method that does what our
> "SEQUENCE_TABLE" builtin does then we can point you to the relevant  
> bits of
> code in our CVS.
>
>
> -- 
> Andy
>

Craig Russell
Architect, Sun Java Enterprise System http://java.sun.com/products/jdo
408 276-5638 mailto:Craig.Russell@sun.com
P.S. A good JDO? O, Gasp!


Mime
View raw message