db-jdo-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Karan Malhi <karan.ma...@gmail.com>
Subject Re: jpox cannot find sequence
Date Sun, 18 Sep 2005 16:04:32 GMT
Hi Craig,

looks pretty good to me.


Right now the jdo dtd allows me to specify xml meta-data as

<sequence name="TestSequence" factory-class="
javax.jdo.datastore.SimpleSequenceFactory" 
datastore-sequence="SOME_SEQUENCE" strategy="contiguous" />

What would happen in the above case, would a factory sequence be used or 
would a datastore-sequence be used on a call to getSequence("
packagename.TestSequence") ?

What if we had a dtd where factory-class and datastore-sequence could be 
optional child elements

<!ELEMENT sequence ( (factory-class | datastore-sequence)?) >

On 9/17/05, Craig Russell <Craig.Russell@sun.com> wrote:
> 
> 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 <http://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 <Craig.Russell@sun.com>
> 
> P.S. A good JDO? O, Gasp!
> 
> 
> 
> 


-- 
Karan Malhi

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