I would use primkey-field at class level:
@ejb:bean
name="User"
type="CMP"
view-type="local"
primkey-field="name"
schema="User"
cmp-version="2.x"
And then set the name in create method:
public String ejbCreate(String name, UserValue data)
throws CreateException {
setName(name);
setUserValue(data);
//EJB spec
return null;
}
And then define the PK field
/**
* @ejb:pk-field
* @ejb:persistence
* column-name="name"
* jdbc-type="VARCHAR"
* sql-type="varchar(15)"
* @ejb:interface-method
* @ejb:transaction
* type="Supports"
*/
public abstract String getName();
public abstract void setId(String name);
In the case of a "non-repetable-read", you should receive a Create
exception in the service layer ideally implemented within a SessionBean.
This exception can be translated and thrown as a higher level exception
(ie. "AccountCreateException") to the client layer.
In addition the name is defined as a key in the database. This is my
particular approach to the problem please tell me if you don't feel it's
a good one.
Regards
Eduardo
On Wed, 2003-07-30 at 01:35, Jean-philippe VIGNIEL wrote:
> Yes, but my name is no defined as a PK and i don't want to use unicity
> constraint (in fact i don't know if the default jboss database manages
> it, the @pk-constaint tag has no effect.
>
> Moreover, if your name is defined as a PK, you don't need any more to
> check the unicity and you have a wrong design with some rules managed by
> the db tier.
> At least, i've been said that the ejb server can delay the call to
> ejbstore. In this case you get your exception after the call (at the
> end of the transaction i guess) of the create function which can be
> difficult to manage.
>
--
Eduardo H. Ram�rez Rangel
Centro de Sistemas Inteligentes, ITESM
[EMAIL PROTECTED] / [EMAIL PROTECTED]
5o. Piso Torre Sur CETEC, ITESM Campus Monterrey
(52-81) 8328-4380, 83-58-2000. Ext. 5134
-------------------------------------------------------
This SF.Net email sponsored by: Free pre-built ASP.NET sites including
Data Reports, E-commerce, Portals, and Forums are available now.
Download today and enter to win an XBOX or Visual Studio .NET.
http://aspnet.click-url.com/go/psa00100003ave/direct;at.aspnet_072303_01/01
_______________________________________________
xdoclet-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/xdoclet-user