Hello Marco, Sunday, July 06, 2003, 10:39:45 PM, Marco Tedone wrote:
MT> Alexey, I would be interested in writing something useful for Jboss users if MT> possible. Where shall I implemented the bottom interfaces? In an ordinary MT> class? In an EJB? Entity beans don't have to implement these interfaces. The two generators available, are not aware of EJB at all. And can be used by any component in JBoss. But, generally, you could implement these interfaces in EJB. I haven't thought about it, though. MT> Shall I write any code for getFactoryName() and MT> getKeyGenerator()? Yes. getFactoryName returns factory's JNDI name and getKeyGenerator() returns an instance of KeyGenerator. MT> Is the <entity-command> element support by XDoclet AFAYK? Yes, it is supported. MT> May the bottom mentioned interfaces implemented in the same class? I don't see why not. MT> At MT> present we are deciding if implementing Marco Garbelini's solution or a MT> built in solution (by means of a synchronized method). In any case, I will MT> probably ask to one of my developers to build this solution with you, if MT> that is ok for you. Great, let's discuss it. Thank you, alex MT> Regards, MT> Marco MT> ----- Original Message ----- MT> From: "Alexey Loubyansky" <[EMAIL PROTECTED]> MT> To: "Marco Tedone" <[EMAIL PROTECTED]> MT> Sent: Thursday, June 26, 2003 9:51 AM MT> Subject: Re[2]: [JBoss-user] Question about CMP entity >> You need to implement two interfaces (in package MT> org.jboss.ejb.plugins.keygenerator) >> public interface KeyGenerator >> { >> public Object generateKey(); >> } >> >> public interface KeyGeneratorFactory >> { >> public String getFactoryName(); >> public KeyGenerator getKeyGenerator() throws Exception; >> } >> >> Then deploy/bind the factory to JNDI and declare entity-command in >> jbosscmp-jdbc.xml supplying fractory's JNDI name, for example >> <!-- uses key generator to fetch the next key value --> >> <entity-command name="key-generator"> >> <attribute MT> name="key-generator-factory">UUIDKeyGeneratorFactory</attribute> >> </entity-command> >> >> In ejbCreate container calls KeyGenerator.generateKey() to set PK >> value. >> >> There is UUID key generator in 3.2 and there is HiLo generator >> (something like you are going to implement with EJBs) in HEAD. >> >> If you really would like to go this route, feel free to contact me. >> >> BTW, key generation welcomes contributions. In 4.0 it is also used for >> our JDO implementation JBossDO. If anyone is interested in >> contribution, please, contact me. >> >> alex >> >> Thursday, June 26, 2003, 10:15:30 AM, Marco Tedone wrote: >> >> MT> Thank you Alex, I have already received a possible solution from Marco >> MT> Garbelini and I'll try it, but particularly, the one you are MT> suggesting (my >> MT> own key generator class) sounds interesting. How could I implement it MT> in the >> MT> EJB CMP architecture? >> >> MT> Marco >> MT> ----- Original Message ----- >> MT> From: "Alexey Loubyansky" <[EMAIL PROTECTED]> >> MT> To: "Marco Tedone" <[EMAIL PROTECTED]> >> MT> Sent: Thursday, June 26, 2003 7:12 AM >> MT> Subject: Re: [JBoss-user] Question about CMP entity >> >> >> >> Hello Marco, >> >> >> >> if the problem really is a primary key generation you could consider >> >> entity-commands in JBoss-3.2. >> >> The options are: >> >> - database key generation (sequences, etc); >> >> - custom sql; >> >> - you can supply your own key generator class that will be asked for >> >> the next key; >> >> - JDBC3.0 PreparedStatement.getGeneratedKeys(). >> >> >> >> alex >> >> >> >> Thursday, June 26, 2003, 1:06:43 AM, Marco Tedone wrote: >> >> >> >> MT> Sorry guru for the [silly] question: I am having a discussion with >> MT> people in >> >> MT> my project regarding the container work with CMP entity beans. More >> >> MT> specifically, we want to implement a Numerator table to assign MT> numbers >> MT> to >> >> MT> several entities of our model. >> >> >> >> MT> Suppose a client wants to assign a value to a peopleId field in a >> MT> People >> >> MT> table, then it will in order: >> >> >> >> MT> 1) Access the Numerator table (behind a CMP entity bean) >> >> MT> 2) Retrieve the value from the number field; >> >> MT> 3) Assign that value to peopleId >> >> MT> 4) Increment the value by 1 >> >> >> >> MT> What I am saying to the guys in the project is that the container >> MT> (Jboss in >> >> MT> our case) could ensure that, from the moment when the number is >> MT> retrieved to >> >> MT> the moment when the number is incremented by 1 nobody else will be >> MT> able to >> >> MT> alter the value of the number field in the Numerator table. Someone MT> is >> >> MT> replying that we should implement a synchronized method. Is that >> MT> really >> >> MT> necessary? I'm quite sure that there is a way to instruct the >> MT> container to >> >> MT> 'lock' in a certain sense the value of the number field. One way MT> could >> MT> be a >> >> MT> transaction (shall we use synchronization in this case?); is there >> MT> anything >> >> MT> simplier? >> >> >> >> MT> Many thanks for your time, >> >> >> >> MT> Marco ------------------------------------------------------- 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/psa00100006ave/direct;at.asp_061203_01/01 _______________________________________________ JBoss-user mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/jboss-user