RE: Unique column
Here's my recommendation: 1) Implement the PersistenceBrokerAware interface in your persistable object (ie. Employee). 2) In the beforeInsert callback, check the database for a record with an employee name that matches the employee name of "this". 3) In the beforeUpdate callback, check the database for a record with an employee name that matches the employee name of "this" and where the id of the existing record doesn't match the primary key of "this". For steps 2) and 3), you can use the PersistenceBroker that's passed in via the specified callback. For details, check out the javadocs related to the PersistenceBrokerAware interface. Ron Gallagher Atlanta,GA rongallagher at bellsouth dot net -Original Message- From: Muhammad Aamir [mailto:[EMAIL PROTECTED] Sent: Friday, February 13, 2004 7:59 AM To: OJB Users List Subject: RE: Unique column Emp table cannot have ename as it's primary key e.g., (because empno is it's PK). Further, although I asked particularly about unique column actually I wanted to ask that how can we implement business rule that depends on the same table. For example if I don't want to use UNIQE constraint on database level or want to do some query on same table Thank you, Aamir -Original Message- From: Edson Carlos Ericksson Richter [mailto:[EMAIL PROTECTED] Sent: Friday, February 13, 2004 6:46 PM To: OJB Users List Subject: Re: Unique column Short answer: it's all in documentation. Look there. Long answer: As far you have not give more details, just set it as primary key. This guarantee no duplicates, and no nulls. Don't forget to set this in database too (all good databases around the world support primary keys). Other way: in OJB uses it as normal field, and in database create a UNIQUE index. Almost all databases knows the UNIQUE concept. If it need be auto-generated, look docs about auto-increment. If it isn't numeric, and need be unique, you can create your own Sequence Manager. Check docs. Best regards, Edson Richter - Original Message - From: Muhammad Aamir To: OJB Users List Sent: Friday, February 13, 2004 9:25 AM Subject: RE: Unique column Re-post -Original Message- From: Muhammad Aamir Sent: Wednesday, February 11, 2004 9:51 AM To: [EMAIL PROTECTED] Subject: Unique column There is a column that I want it to be unique in the table. How can I implement this business rule ?? Thanks Aamir - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.587 / Virus Database: 371 - Release Date: 12/2/2004 - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Unique column
Emp table cannot have ename as it's primary key e.g., (because empno is it's PK). Further, although I asked particularly about unique column actually I wanted to ask that how can we implement business rule that depends on the same table. For example if I don't want to use UNIQE constraint on database level or want to do some query on same table Thank you, Aamir -Original Message- From: Edson Carlos Ericksson Richter [mailto:[EMAIL PROTECTED] Sent: Friday, February 13, 2004 6:46 PM To: OJB Users List Subject: Re: Unique column Short answer: it's all in documentation. Look there. Long answer: As far you have not give more details, just set it as primary key. This guarantee no duplicates, and no nulls. Don't forget to set this in database too (all good databases around the world support primary keys). Other way: in OJB uses it as normal field, and in database create a UNIQUE index. Almost all databases knows the UNIQUE concept. If it need be auto-generated, look docs about auto-increment. If it isn't numeric, and need be unique, you can create your own Sequence Manager. Check docs. Best regards, Edson Richter - Original Message - From: Muhammad Aamir To: OJB Users List Sent: Friday, February 13, 2004 9:25 AM Subject: RE: Unique column Re-post -Original Message- From: Muhammad Aamir Sent: Wednesday, February 11, 2004 9:51 AM To: [EMAIL PROTECTED] Subject: Unique column There is a column that I want it to be unique in the table. How can I implement this business rule ?? Thanks Aamir - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.587 / Virus Database: 371 - Release Date: 12/2/2004 - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Unique column
Short answer: it's all in documentation. Look there. Long answer: As far you have not give more details, just set it as primary key. This guarantee no duplicates, and no nulls. Don't forget to set this in database too (all good databases around the world support primary keys). Other way: in OJB uses it as normal field, and in database create a UNIQUE index. Almost all databases knows the UNIQUE concept. If it need be auto-generated, look docs about auto-increment. If it isn't numeric, and need be unique, you can create your own Sequence Manager. Check docs. Best regards, Edson Richter - Original Message - From: Muhammad Aamir To: OJB Users List Sent: Friday, February 13, 2004 9:25 AM Subject: RE: Unique column Re-post -Original Message- From: Muhammad Aamir Sent: Wednesday, February 11, 2004 9:51 AM To: [EMAIL PROTECTED] Subject: Unique column There is a column that I want it to be unique in the table. How can I implement this business rule ?? Thanks Aamir - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.587 / Virus Database: 371 - Release Date: 12/2/2004
RE: Unique column
Re-post -Original Message- From: Muhammad Aamir Sent: Wednesday, February 11, 2004 9:51 AM To: [EMAIL PROTECTED] Subject: Unique column There is a column that I want it to be unique in the table. How can I implement this business rule ?? Thanks Aamir - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]