• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

BMP without Primary key

 
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Is it possible to develop a BMP for a database table having no primary key field.
 
Ranch Hand
Posts: 128
Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
yes it is possible...as you manage your own persistence and you over ride the load and store methods..you can do it. you can even map more than one Table to an Entity Bean with BMP..
 
Ranch Hand
Posts: 289
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I wonder how you are going to access the Bean though, because I understand the Primary Key is used to get a handle on specific bean instances.
Herbert.
 
Raj Chila
Ranch Hand
Posts: 128
Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Good Question,
But I feel that as for Session beans, the container takes care of creating an identity for the bean with BMP and this will be used by the Handle also. and so calling on remove by Primary key class throws an Exception..
and same as a BMP the handle can be useful (for serialization and invoking over other JVMS etc) as long as the BMP exists in the memory...
Need to look at ths specs once..before I can say for sure.
 
Herbert Maosa
Ranch Hand
Posts: 289
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Rajan,
I think that this question is specific to entity beans, because there is no Persistence of any kind in Session Beans. So I would think that the fact that Raj asks about BMP ( Bean Managed Persistence ) automatically tells us we are dealing with Entity Beans with Bean Managed Persistence. If this is the case, the Sun App Server will not pass the Bean on the J2EE compliance test, if it lacks the primary key.
Herbert.
 
Raj Jindal
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes guys, I am talking about bean Managed Persistence (BMP) mapping to a table with duplicate records or without primary key
 
Herbert Maosa
Ranch Hand
Posts: 289
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Raj,
My feeling is that you HAVE to have a primary key for a proper implementation of BMP according to the J2EE spec. After all, a good database design will yield a normalised database that will call for a primary key and eliminate redundancies in the tables.
Herbert.
 
Ranch Hand
Posts: 1066
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think you need a primary key, even it is a BMP.
Both ejbFindByPrimaryKey() and ejbCreate() return primary key objects.
 
Raj Chila
Ranch Hand
Posts: 128
Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi guys,
I was not around to note the comments made...well to start with I know what Raj (Jindal) was talking about.
I was referring to the scenario in case there is not PrimaryKey for the Entity Bean with Bean Managed Persistence. well I admit my wrong that the container provides an Identity (Handle) for the Entity Bean with BMP without a PrimaryKey (as in the case of the Session beans). well we need to provide a Primary Key.
Well Rajs requirement can still be achieved, what the Container needs is a PrimaryKey class and not a Primary Key ( in terms of RDBMS concepts). This is particularly possible because we are using Bean Managed Persistence, we need to create our PrimaryKey class.
lets not forget that we have to override all the lifecycle methods ourselves and the Container does not offer any guarantee of contract...
in case there is no primary key in a table you can still implement the functionality by providing a business level constraint that will allow us to find a unique record. like a unique key spanning more than one column.
if you still insist that the we cannot find the unique record with the column attributes, then your life cycle methods should return a collection of the Primarykey Class or generate a unique key in the create Method and return that PrimaryKey Class.
if this is not possible, then it would be a nightmare for the companies who want to upgrade to EJBs using BMP and implementing the CMP would be out of question. but another question is would there be a design where people wont force unique key constraints, that is remote....but hey it is not impossible either
just for your reference here is a quote from the ejb 1.1 sepcs

infact Raj has asked a thought provoking Question and I think I will workout an example on these lines and confirm asap...


JavaBeans v1.1, Final Release Application Assembler�s responsibility
11/24/99 242
Sun Microsystems Inc.
Entity bean�s primary key class. If the enterprise bean is an Entity bean, the Bean Provider specifies the fully-qualified name of the Entity bean�s primary key class in the prim-key-class element. The Bean Provider must specify the primary key class for an Deployment descriptor Enterprise Entity with bean-managed persistence, and may (but is not required to) specify the primary key class for an Entity with container-managed persistence.


[ April 02, 2004: Message edited by: RajaniKanth Bhargava ]
 
She's out of the country right now, toppling an unauthorized dictatorship. Please leave a message with this tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic