cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Joose Vettenranta <jo...@iki.fi>
Subject Re: OJB + postgresql + "autoincrement"
Date Tue, 20 Jul 2004 16:48:39 GMT
Nope, does not work.

in flow I have like this:
         form.save(bean); // tallenna formin data beaniin
         bean = dao.insert(bean, factory); // kirjoita bean levylle..
         cocoon.releaseComponent(factory); // factoryista eroon...
         cocoon.redirectTo ("info-" + bean.getId() + ".html" );

and CategoryDAO has like this:
     public Category insert(Category cat, JdoPMF pmf) {
         PersistenceManager persistenceManager =  
pmf.getPersistenceManager();
         Transaction tx = persistenceManager.currentTransaction();
         tx.begin();
         persistenceManager.makePersistent (cat);
         tx.commit();
         return cat;
     }

although, according to  
http://db.apache.org/ojb/docu/howtos/howto-use-db-sequences.html I  
perhaps should do it in another way?

repository.xml has like this:

<sequence-manager  
className="org.apache.ojb.broker.util.sequence.SequenceManagerNextValImp 
l" />

and

     <class-descriptor class="net.vettenranta.bean.Category"  
table="categories">
         <field-descriptor name="id"
                           jdbc-type="INTEGER"
                           primarykey="true"
                           default-fetch="true"
                           access="readonly"
                           column="id" />
         <field-descriptor name="parent" column="parent"  
jdbc-type="INTEGER"/>
     </class-descriptor>

According to postgrel, only one INSERT happens, nothing else.

I'll try the example way to use broker... maybe that'll help

- Joose

20.7.2004 kello 18:05, Mike Ahlers kirjoitti:

  But now.. just how do I update that bean to have that Id after insert?
>
> Have your DAO return the (updated) bean and you shall see it has the  
> new Id already set.
>
> --
> Mike Ahlers
>
> Hippo Webworks
> Oosteinde 9
> 1017 WT Amsterdam
> The Netherlands
> Tel  +31 (0)20 5224466
> Fax +31 (0)20 5224467
> ---------------------------------------
> m.ahlers@hippo.nl / www.hippo.nl
> ---------------------------------------
>
>
> -----Original Message-----
> From: Joose Vettenranta [mailto:joose@iki.fi]
> Sent: Tuesday, July 20, 2004 5:02 PM
> To: users@cocoon.apache.org
> Subject: Re: OJB + postgresql + "autoincrement"
>
>
> And finding solution again.. Solution was to put that id field as
> read-only.
>
> But now.. just how do I update that bean to have that Id after insert?
>
> - Joose
>
> 20.7.2004 kello 17:50, Joose Vettenranta kirjoitti:
>
>   Hi,
>>
>> now that I got working the receiving point and inserting sort works..
>> but how do I use autoincrement thing in postgres? (using cocoon in
>> connection pooling).
>>
>> inserting when id is not set, inserts 0 as id. which of course causes
>> error.
>>
>> I tried to look that ojb example from wiki, but it didn't use cocoon
>> connection pool. Example file in cocoon source didn't have any
>> autoincrement in it.
>>
>> Postgresql table is like this:
>> create table category ( id serial, parent integer );
>>
>> Thanks, Joose
>>
>> --
>> "Always remember that you are unique, just like everyone else!"
>> * http://iki.fi/joose/ * joose@iki.fi * +358 44 561 0270 *
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
>> For additional commands, e-mail: users-help@cocoon.apache.org
>>
>>
> --
> "Always remember that you are unique, just like everyone else!"
> * http://iki.fi/joose/ * joose@iki.fi * +358 44 561 0270 *
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org
>
>
--
"Always remember that you are unique, just like everyone else!"
* http://iki.fi/joose/ * joose@iki.fi * +358 44 561 0270 *


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Mime
View raw message