How about using a finder method in the Session Bean like the following.
We have defined a customized finder method (findByIdOrEmail) that checks
that user name or email exists in database.
try {
home.findByIdOrEmail(user_name, email);
throw new CreateException("User name or email already exist");
}
catch ( FinderException f ) {
/* username and email are new, create user */
UserValue uv = new UserValue(user_name,
first_name, last_name,
email, password);
UserLocal user = home.create(user_name, uv);
return user.getId();
}
The ejbdoclet code for the finder method:
@ejb:finder
signature="User findByIdOrEmail(java.lang.String id, java.lang.String
email)"
query="SELECT DISTINCT OBJECT(user) FROM User As user WHERE user.id=?1
OR user.email=?2"
On Mon, 2003-07-28 at 07:16, Jean-philippe VIGNIEL wrote:
> Hi everybody
>
> I have to check that a name is unique before creating or updating this
> object. How can i do that without using a database constraint and
> without concurrency problem?
> The jboss pk-constraint tag set the constaints on the database, is there
> something to do the same thing managed by the container?
>
> Thanks for your help
>
> Jean-Philippe
>
>
>
> -------------------------------------------------------
> 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
--
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