RE: [JBoss-user] create(), ejbCreate() and id

2001-06-25 Thread Jay Walters

It's generally more performant and robust for an enterprise database
(oracle, db2, ms-sql, sybase, informix,...) to be generating the keys, they
have been doing this for some time and are pretty well optimized.  They
generally support very inexpensive methods to get the new key value back
(not re-qeurying the row just inserted) though the further along into this
you get, the more proprietary it will be.  It eliminates a second point of
failure (if the database can't generate the key you probably can't insert
the row anyways) but a separate bean could be unavailable even if the
database is.

One rub is that you in general cannot use these features with CMP beans
because JAWS doesn't support it.  I do this with BMP beans and a stored
procedure (where supported) which allows me to write portable Java/JDBC code
even if the implementation of the stored procedure is database specific.

Cheers
Jay

-Original Message-
From: David Jencks [mailto:[EMAIL PROTECTED]]
Sent: Saturday, June 23, 2001 11:49 PM
To: [EMAIL PROTECTED]
Subject: Re: [JBoss-user] create(), ejbCreate() and id


Hi,

On 2001.06.23 18:11:57 -0400 [EMAIL PROTECTED] wrote:
 On Sat, Jun 23, 2001 at 11:25:32AM -0700, Konstantin Priblouda wrote:
  
   This interests me. I will be doing a project where I
   don't care much
   what the primary keys are, only that they are there
   and are unique
   (obviously). Ideally, I would have the database
   autogenerate a
   sequence of numbers, but there doesn't seem to be a
   way to get the
   Container to do this for me?
  
  Using database for it seems messy for me - you insert
  the row, and everything is fine (assumed your sequence
  or autonumbering worked), but getting this ID out of
  database is not convenient (and highly database
  dependent). That's why I prefer to use separate bean
  to generate ID's
 
 I seem to vaguely recall from when I used MS Access years ago that it
 had a special value type for auto-counter coloumns. You'd just define
 a coloumn and set it as a counter and everything happened
 automatically. It's something like this I'd want. It seems to me that
 this is a common thing to want to do and the database manager doing it
 would presumably be a lot more effecient than the application doing
 so.
 
When I first encountered sequences/generators rather than autoincrement
fields I shared your sentiments.  However, using autoincrement fields has
many problems, and is not necessarily faster.
- You have to read the row again to find outs its only identifying
characteristic.
- There is often (depending on how thoughtless the implementation is) no
way to copy these rows (into another table and back) and get meaningful
results (you get a whole new set of ids, thus totally messing up foreign
keys)

- Using a sequence/generator can reduce db access (in the absence of
triggers modifying the row you just inserted): you can get id's in large
chunks and hand them out, only asking for more when you run out.

davud jencks


___
JBoss-user mailing list
[EMAIL PROTECTED]
http://lists.sourceforge.net/lists/listinfo/jboss-user

___
JBoss-user mailing list
[EMAIL PROTECTED]
http://lists.sourceforge.net/lists/listinfo/jboss-user



Re: [JBoss-user] create(), ejbCreate() and id

2001-06-25 Thread danch (Dan Christopherson)

Jay Walters wrote:

 
 One rub is that you in general cannot use these features with CMP beans
 because JAWS doesn't support it.  


You can in limited ways: you're quite free to get a value from a 
sequence (Postgres or Oracle) within your ejbCreate code. I believe this 
is generally a pretty good comprimise.

-danch




___
JBoss-user mailing list
[EMAIL PROTECTED]
http://lists.sourceforge.net/lists/listinfo/jboss-user



Re: [JBoss-user] create(), ejbCreate() and id

2001-06-25 Thread Konstantin Priblouda


--- danch (Dan Christopherson) [EMAIL PROTECTED]
wrote:
 Jay Walters wrote:
 
  
  One rub is that you in general cannot use these
 features with CMP beans
  because JAWS doesn't support it.  
 
 
 You can in limited ways: you're quite free to get a
 value from a 
 sequence (Postgres or Oracle) within your ejbCreate
 code. I believe this 
 is generally a pretty good comprimise.

Which voids the very idea of CMP :)
Why do I need it ( CMP ), if I still have to obtain
connection and call something on database backend
myself?

regards,

=
Konstantin Priblouda ( ko5tik )Freelance Software developer
 http://www.pribluda.de   play java games - http://www.yook.de 
 render charts online - http://www.pribluda.de/povray/ 

__
Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail
http://personal.mail.yahoo.com/

___
JBoss-user mailing list
[EMAIL PROTECTED]
http://lists.sourceforge.net/lists/listinfo/jboss-user



Re: [JBoss-user] create(), ejbCreate() and id

2001-06-25 Thread danch (Dan Christopherson)

Konstantin Priblouda wrote:


 
 Which voids the very idea of CMP :)
 Why do I need it ( CMP ), if I still have to obtain
 connection and call something on database backend
 myself?
 

This is one call, and it has the tremendous advantage that it will work. 
You're still not writing separate insert, update, delete, and one query 
per finder method. Also, BMP finders returning collections are very 
innefficient, whereas with CMP the container has the opportunity to 
optimize this. In JBoss 2.4, CMP collection finders are optimizable.


___
JBoss-user mailing list
[EMAIL PROTECTED]
http://lists.sourceforge.net/lists/listinfo/jboss-user



Re: [JBoss-user] create(), ejbCreate() and id

2001-06-25 Thread Allen fogleson

if not db independent. I freely admit we do this all the time. we dont do it
in the ejbCreate... we do it before calling create, but same difference.
recently i had to write some components (really a set of beans/tags/jsps)
that would work on (potentially) several databases... it was a little more
difficult :)

Al
- Original Message -
From: danch (Dan Christopherson) [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Monday, June 25, 2001 10:06 AM
Subject: Re: [JBoss-user] create(), ejbCreate() and id


 You can in limited ways: you're quite free to get a value from a
 sequence (Postgres or Oracle) within your ejbCreate code. I believe this
 is generally a pretty good comprimise.

 -danch




 ___
 JBoss-user mailing list
 [EMAIL PROTECTED]
 http://lists.sourceforge.net/lists/listinfo/jboss-user


___
JBoss-user mailing list
[EMAIL PROTECTED]
http://lists.sourceforge.net/lists/listinfo/jboss-user



Re: [JBoss-user] create(), ejbCreate() and id

2001-06-23 Thread Konstantin Priblouda


 In a CD tutorial example I do not understand the
 role of id parameter in ejbCreate(String) method and
 who supplies this string and how. Is it the way EJB
 provides unique field for easy primary key
 implementation? Should I necessarily have such a
 field name in my
 bean and should I implement ejbCreate always with
 this signature? I am especially curious because I
 previously implemented non-argument ejbCreate() and
 got id is null failure message on deployment.

Your EJB shall have primary key. ( and it could be
whatever field you like ). On creation of your EJB
you have to generate this key yourself. 

I use an separate bean as sequence generator.


regards,

=
Konstantin Priblouda ( ko5tik )Freelance Software developer
 http://www.pribluda.de   play java games - http://www.yook.de 
 render charts online - http://www.pribluda.de/povray/ 

__
Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail
http://personal.mail.yahoo.com/

___
JBoss-user mailing list
[EMAIL PROTECTED]
http://lists.sourceforge.net/lists/listinfo/jboss-user



Re: [JBoss-user] create(), ejbCreate() and id

2001-06-23 Thread Vinay Menon
Must add that you should be able to create Entity Beans without primary keys as well. As to what data they represent is obvious hence.  Vinay   - Original Message - From: Konstantin Priblouda Sent: Saturday, June 23, 2001 6:00 PM To: [EMAIL PROTECTED] Subject: Re: [JBoss-user] create(), ejbCreate() and   In a CD tutorial example I do not understand the role of id parameter in ejbCreate(String) method and who supplies this string and how. Is it the way EJB provides unique field for easy primary key implementation? Should I necessarily have such a field name in my bean and should I implement ejbCreate always with this signature? I am especially curious because I previously implemented non-argument ejbCreate() and got "id is null" failure message on deployment.Your EJB shall have primary key. ( and it could bewhatever field you like ). On creation of your EJByou have to generate this key yourself.I use an separate bean as sequence generator.regards,=Konstantin Priblouda ( ko5tik ) Freelance Software developer http://www.pribluda.de   play java games - http://www.yook.de  render charts online - http://www.pribluda.de/povray/ __Do You Yahoo!?Get personalized email addresses from Yahoo! Mailhttp://personal.mail.yahoo.com/___JBoss-user mailing list[EMAIL PROTECTED]http://lists.sourceforge.net/lists/listinfo/jboss-userGet more from the Web.  FREE MSN Explorer download : http://explorer.msn.com


Re: [JBoss-user] create(), ejbCreate() and id

2001-06-23 Thread bcd

On Sat, Jun 23, 2001 at 09:58:12AM -0700, Konstantin Priblouda wrote:
 
 Your EJB shall have primary key. ( and it could be
 whatever field you like ). On creation of your EJB
 you have to generate this key yourself. 
 
 I use an separate bean as sequence generator.

This interests me. I will be doing a project where I don't care much
what the primary keys are, only that they are there and are unique
(obviously). Ideally, I would have the database autogenerate a
sequence of numbers, but there doesn't seem to be a way to get the
Container to do this for me?

Could you describe your sequence generator? It sounds like the thing
that I need.

Cheers
Bent D
-- 
Bent Dalager - [EMAIL PROTECTED] - http://www.pvv.org/~bcd
powered by emacs

___
JBoss-user mailing list
[EMAIL PROTECTED]
http://lists.sourceforge.net/lists/listinfo/jboss-user



Re: [JBoss-user] create(), ejbCreate() and id

2001-06-23 Thread Konstantin Priblouda


 This interests me. I will be doing a project where I
 don't care much
 what the primary keys are, only that they are there
 and are unique
 (obviously). Ideally, I would have the database
 autogenerate a
 sequence of numbers, but there doesn't seem to be a
 way to get the
 Container to do this for me?

Using database for it seems messy for me - you insert
the row, and everything is fine (assumed your sequence
or autonumbering worked), but getting this ID out of
database is not convenient (and highly database
dependent). That's why I prefer to use separate bean
to generate ID's

 Could you describe your sequence generator? It
 sounds like the thing
 that I need.

I posted archive with complete source a week ago on
the list (look in the archive). There is also ejbutil
project on sourceforge
( they also have something like this )


And here is short outline what bean does:

It has primary key ( string ID to locate it ),
it has increment, current value and method getNext()
which advances it. 
Whenever I need an ID, I lookup this bean by primary
key ( I store value of this primary key as String data
in ejb environment ), and then just call getNext()

no magic, just some voodoo :)



=
Konstantin Priblouda ( ko5tik )Freelance Software developer
 http://www.pribluda.de   play java games - http://www.yook.de 
 render charts online - http://www.pribluda.de/povray/ 

__
Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail
http://personal.mail.yahoo.com/

___
JBoss-user mailing list
[EMAIL PROTECTED]
http://lists.sourceforge.net/lists/listinfo/jboss-user



Re: [JBoss-user] create(), ejbCreate() and id

2001-06-23 Thread bcd

On Sat, Jun 23, 2001 at 11:25:32AM -0700, Konstantin Priblouda wrote:
 
  This interests me. I will be doing a project where I
  don't care much
  what the primary keys are, only that they are there
  and are unique
  (obviously). Ideally, I would have the database
  autogenerate a
  sequence of numbers, but there doesn't seem to be a
  way to get the
  Container to do this for me?
 
 Using database for it seems messy for me - you insert
 the row, and everything is fine (assumed your sequence
 or autonumbering worked), but getting this ID out of
 database is not convenient (and highly database
 dependent). That's why I prefer to use separate bean
 to generate ID's

I seem to vaguely recall from when I used MS Access years ago that it
had a special value type for auto-counter coloumns. You'd just define
a coloumn and set it as a counter and everything happened
automatically. It's something like this I'd want. It seems to me that
this is a common thing to want to do and the database manager doing it
would presumably be a lot more effecient than the application doing
so.

 
  Could you describe your sequence generator? It
  sounds like the thing
  that I need.
 
 I posted archive with complete source a week ago on
 the list (look in the archive). There is also ejbutil
 project on sourceforge
 ( they also have something like this )

Thanks.

Cheers
Bent D
-- 
Bent Dalager - [EMAIL PROTECTED] - http://www.pvv.org/~bcd
powered by emacs

___
JBoss-user mailing list
[EMAIL PROTECTED]
http://lists.sourceforge.net/lists/listinfo/jboss-user



Re: [JBoss-user] create(), ejbCreate() and id

2001-06-23 Thread David Jencks

Hi,

On 2001.06.23 18:11:57 -0400 [EMAIL PROTECTED] wrote:
 On Sat, Jun 23, 2001 at 11:25:32AM -0700, Konstantin Priblouda wrote:
  
   This interests me. I will be doing a project where I
   don't care much
   what the primary keys are, only that they are there
   and are unique
   (obviously). Ideally, I would have the database
   autogenerate a
   sequence of numbers, but there doesn't seem to be a
   way to get the
   Container to do this for me?
  
  Using database for it seems messy for me - you insert
  the row, and everything is fine (assumed your sequence
  or autonumbering worked), but getting this ID out of
  database is not convenient (and highly database
  dependent). That's why I prefer to use separate bean
  to generate ID's
 
 I seem to vaguely recall from when I used MS Access years ago that it
 had a special value type for auto-counter coloumns. You'd just define
 a coloumn and set it as a counter and everything happened
 automatically. It's something like this I'd want. It seems to me that
 this is a common thing to want to do and the database manager doing it
 would presumably be a lot more effecient than the application doing
 so.
 
When I first encountered sequences/generators rather than autoincrement
fields I shared your sentiments.  However, using autoincrement fields has
many problems, and is not necessarily faster.
- You have to read the row again to find outs its only identifying
characteristic.
- There is often (depending on how thoughtless the implementation is) no
way to copy these rows (into another table and back) and get meaningful
results (you get a whole new set of ids, thus totally messing up foreign
keys)

- Using a sequence/generator can reduce db access (in the absence of
triggers modifying the row you just inserted): you can get id's in large
chunks and hand them out, only asking for more when you run out.

davud jencks


___
JBoss-user mailing list
[EMAIL PROTECTED]
http://lists.sourceforge.net/lists/listinfo/jboss-user



[JBoss-user] create(), ejbCreate() and id

2001-06-22 Thread Boris Garbuzov

In a CD tutorial example I do not understand the role of id parameter in 
ejbCreate(String) method and who supplies this string and how. Is it the way EJB 
provides unique field for easy primary key implementation? Should I necessarily have 
such a field name in my
bean and should I implement ejbCreate always with this signature? I am especially 
curious because I previously implemented non-argument ejbCreate() and got id is null 
failure message on deployment.


___
JBoss-user mailing list
[EMAIL PROTECTED]
http://lists.sourceforge.net/lists/listinfo/jboss-user