Hi Guillaume,

1. I faced the same Problem with auto-increment keys in a Sybase
database. One of the several ways to do it is to have two different
Entity Beans with the same PK. One of them in CMP without any create
methods and one in BMP implementing only the create methods. This second
one gets all the parameters except for the PK and after insertion into
the database performs a SELECT @@identity (Sybase) to retrieve the
generated PK. After creating this bean you can call a method to get the
PK of the newly generated bean and use it to find the CMP Entity Bean.
Of course, this is a little overhead. But considering that creating
Beans is a rare case and doing it like this, you don't have to
completely implement a BMP Entity Bean.

2. As far as I know and what my tests showed, when using isModified in
Jonas doesn't prevent the ejbStore() method to be called. The decision,
wheter the Bean should be stored or not, is somewhere beyond.
Unfortunately, I couldn't find a reasonable explanation for this yet.

dirk


Guillaume Rousse wrote:
> 
> Hi;
> I use jonas for a web-based library-like application. So, i use three entity
> beans (authors, subjects, and documents) and a stateless session bean (biblio)
> for accessing them. All sessions beans are BMP in order to have postgreSQL
> automatically generating primary keys at insert time (if there were a way to do
> this with BMP, i would be interested). I've used isModified method to avoid
> useless transactions. Altough, i'm rather effraid by the number of transactions
> encountered for a simple lookup:
> Here's a short commented log extract, showing all non-business method and
> SQL queries:
> [EMAIL PROTECTED]()
> [EMAIL PROTECTED]()
> [EMAIL PROTECTED]()
> // My SB is initialized, and lookup method is called : ok
> 
> [EMAIL PROTECTED]()
> [EMAIL PROTECTED]()
>   select oid from document order
> // This is a general findall method in my entitybeans superclass
> 
> by titre [EMAIL PROTECTED]()
>   select * from document where oid=27362
>   select * from document_auteur where document_oid=27362
>   select * from document_rubrique where document_oid=27362
> // This shows tha       t a first EB is used for lookup, and others for
> instanciation. Isn't it a waste of ressource, where a SB could do lookup also ?
> 
> [EMAIL PROTECTED]()
> // why already store a just-loaded bean ?
> 
> [EMAIL PROTECTED]()
> select * from auteur where oid=26600
> update document set titre='Apport du mod�le objet en syst�matique',resume='Avantages 
>du mod�le objet pour r�pondre aux besoins actuels de repr
> �sentation des connaissances en 
>syst�matique',url='',date_publication='2000-04-15',auteur_publication_oid=26600 where 
>oid=27362
> delete from document_auteur where document_oid=27362
> insert into document_auteur (document_oid,auteur_oid) values(27362,26600)
> delete from document_rubrique where document_oid=27362
> [EMAIL PROTECTED]()
> select * from rubrique where oid=27361
> insert into document_rubrique (document_oid,rubrique_oid) values(27362,27361)
> [EMAIL PROTECTED]()
> select * from rubrique where oid=27568
> insert into document_rubrique (document_oid,rubrique_oid) values(27362,27568)
> [EMAIL PROTECTED]()
> update auteur set prenom='Guillaume',nom='Rousse' where oid=26600
> [EMAIL PROTECTED]()
> update rubrique set nom='syst�matique',parent_oid=0 where oid=27361
> [EMAIL PROTECTED]()
> [EMAIL PROTECTED]()
> select * from rubrique where oid=27360
> update rubrique set nom='mod�le objet',parent_oid=27360 where oid=27568
> [EMAIL PROTECTED]()
> // explanation : there is one author, and three subjects (rubriques) for my
> document, and each is also loaded first, then stored as soon, as the document.
> Same remark as above : why ?
> 
> [EMAIL PROTECTED]()
> select * from document where oid=27362
> select * from document_auteur where document_oid=27362
> select * from document_rubrique where document_oid=27362
> [EMAIL PROTECTED]()
> [EMAIL PROTECTED]()
> select * from auteur where oid=26600
> update document set titre='Apport du mod�le objet en syst�matique',resume='Avantages 
>du mod�le objet pour r�pondre aux besoins actuels de repr�sentation des connaissances 
>en syst�matique',url='',date_publication='2000-04-15',auteur_publication_oid=26600 
>where oid=27362
> delete from document_auteur where document_oid=27362
> insert into document_auteur (document_oid,auteur_oid) values(27362,26600)
> delete from document_rubrique where document_oid=27362
> [EMAIL PROTECTED]()
> select * from rubrique where oid=27361
> insert into document_rubrique (document_oid,rubrique_oid) values(27362,27361)
> [EMAIL PROTECTED]()
> select * from rubrique where oid=27568
> insert into document_rubrique (document_oid,rubrique_oid) values(27362,27568)
> [EMAIL PROTECTED]()
> update auteur set prenom='Guillaume',nom='Rousse' where oid=26600
> [EMAIL PROTECTED]()
> update rubrique set nom='syst�matique',parent_oid=0 where oid=27361
> [EMAIL PROTECTED]()
> [EMAIL PROTECTED]()
> select * from rubrique where oid=27360
> update rubrique set nom='mod�le objet',parent_oid=27360 where oid=27568
> [EMAIL PROTECTED]()
> update rubrique set nom='informatique',parent_oid=0 where oid=27360
> // And all this stuff happens again, 5 times at all...
> 
> Altough of caching objects, in fact i have unstopping queries against my
> database. I imagine overall 5 time repetition can be caused by a poor
> relationships design, but not the load/store immedialty process, neither the
> wasted EB for lookup. What have i missed ?
> 
>   --
> Guillaume Rousse
> Iremia - Universit� de la R�union
> 
> Sleep doesn't exists. Just lack of cafeine.
> ----
> To unsubscribe, send email to [EMAIL PROTECTED] and
> include in the body of the message "unsubscribe jonas-users".
> For general help, send email to [EMAIL PROTECTED] and
> include in the body of the message "help".

--
Dirk Haase                            Schlund + Partner AG
[EMAIL PROTECTED]                      http://www.schlund.de
----
To unsubscribe, send email to [EMAIL PROTECTED] and
include in the body of the message "unsubscribe jonas-users".
For general help, send email to [EMAIL PROTECTED] and
include in the body of the message "help".

Reply via email to