Re: Duplicate Key in Db

2005-02-24 Thread Brice Ruth
ch > > choice, because of the libraries you use (in particular JDBC, but you could > > find many other examples in Java libs). > > > > Just my 2c > > > > Cheers > > > > Jean-Francois > > > > -Original Message- > > From:

Re: Duplicate Key in Db

2005-02-24 Thread Larry Meadors
] > Sent: Thursday, February 24, 2005 11:08 AM > To: ibatis-user-java@incubator.apache.org > Subject: Re: Duplicate Key in Db > > To be honest... that sounds like a bad decision. Using database error > codes to determine application flow is very subjective and dangerous. > I c

RE: Duplicate Key in Db

2005-02-24 Thread Jean-Francois Poilpret
TED] Sent: Thursday, February 24, 2005 11:08 AM To: ibatis-user-java@incubator.apache.org Subject: Re: Duplicate Key in Db To be honest... that sounds like a bad decision. Using database error codes to determine application flow is very subjective and dangerous. I could see passing a human readable error

Re: Duplicate Key in Db

2005-02-23 Thread Brandon Goodin
ption. It should hold a vendor > > specific code that identifies the type of database error. > > > > - Original Message - > > From: "Brice Ruth" <[EMAIL PROTECTED]> > > To: ibatis-user-java@incubator.apache.org, "Tim Christopher"

Re: Duplicate Key in Db

2005-02-23 Thread Brandon Goodin
SQLException? > > -Original Message- > From: Tim Christopher [mailto:[EMAIL PROTECTED] > Sent: Wednesday, February 23, 2005 11:06 AM > To: ibatis-user-java@incubator.apache.org > Subject: Re: Duplicate Key in Db > > Sorry, I should have mentioned that I was talking about an ins

Re: Duplicate Key in Db

2005-02-23 Thread Brandon Goodin
You are simply performing error interpreatation for user consumption. So, no matter what SQLException gets thrown it will simply display an error to the user. However, i would not recommend that you get into the practice of deciding how to proceed based upon the type of SQLException that is being t

Re: Duplicate Key in Db

2005-02-23 Thread Tim Christopher
My probably goes a little against the grain of what you are saying, though I've only just read your comments... What I've done is to extend the framework to allow iBATIS to return an int for insertions calls, then created a constants file (as a HashMap) to turn returned values into entries from th

Re: Duplicate Key in Db

2005-02-23 Thread Brandon Goodin
rry Meadors [mailto:[EMAIL PROTECTED] > Sent: Thursday, February 24, 2005 4:02 AM > To: ibatis-user-java@incubator.apache.org > Subject: Re: Duplicate Key in Db > > Man guys, this is going down a really ugly path. > > What happens when you get a new driver, and the message

Re: Duplicate Key in Db

2005-02-23 Thread Brandon Goodin
ption. It should hold a vendor > > specific code that identifies the type of database error. > > > > - Original Message - > > From: "Brice Ruth" <[EMAIL PROTECTED]> > > To: ibatis-user-java@incubator.apache.org, "Tim Christopher"

RE: Duplicate Key in Db

2005-02-23 Thread Jean-Francois Poilpret
Meadors [mailto:[EMAIL PROTECTED] Sent: Thursday, February 24, 2005 4:02 AM To: ibatis-user-java@incubator.apache.org Subject: Re: Duplicate Key in Db Man guys, this is going down a really ugly path. What happens when you get a new driver, and the message changes from "Invalid key" to &qu

Re: Duplicate Key in Db

2005-02-23 Thread Larry Meadors
; specific code that identifies the type of database error. > > - Original Message - > From: "Brice Ruth" <[EMAIL PROTECTED]> > To: ibatis-user-java@incubator.apache.org, "Tim Christopher" <[EMAIL > PROTECTED]> > Subject: Re: Duplicate Key

Re: Duplicate Key in Db

2005-02-23 Thread Brent Worden
ibatis-user-java@incubator.apache.org, "Tim Christopher" <[EMAIL PROTECTED]> Subject: Re: Duplicate Key in Db Date: Wed, 23 Feb 2005 14:32:25 -0600 > > I think you need to catch a DaoException, and check its cause. If its > cause is a NestedSqlException, you'll need to interrogate

Re: Duplicate Key in Db

2005-02-23 Thread Brice Ruth
I think you need to catch a DaoException, and check its cause. If its cause is a NestedSqlException, you'll need to interrogate that to determine what the "real" cause was. In your case, it appears a generic exception is thrown by the JDBC driver (com.borland.datastore.driver.SqlState), with a "Run

Re: Duplicate Key in Db

2005-02-23 Thread Tim Christopher
>> You can do that now. Maybe I'm missing something? >> The Ibatis insert() statement throws a SQLException.. .. Below is the first part of stack dump that is triggers by the failed insertion, so should I be catching a DaoException or NestedSQLException?... Or is there anything else I can do? >

Re: Duplicate Key in Db

2005-02-23 Thread Larry Meadors
Have you considered a stored procedure for this? If the rules surrounding the data are as complex and fluid as they sound, that may be the easiest way to centralize the managment of them. Larry On Wed, 23 Feb 2005 18:54:02 +, Tim Christopher <[EMAIL PROTECTED]> wrote: > So what happens if y

RE: Duplicate Key in Db

2005-02-23 Thread Akins, Greg
PROTECTED] Sent: Wednesday, February 23, 2005 1:54 PM To: ibatis-user-java@incubator.apache.org Subject: Re: Duplicate Key in Db So what happens if you have a SQL statement that inserts data into serveral tables. Every change to the database would require you to reevaluate what checks (select statem

Re: Duplicate Key in Db

2005-02-23 Thread Tim Christopher
So what happens if you have a SQL statement that inserts data into serveral tables. Every change to the database would require you to reevaluate what checks (select statements) need to be done to ensure a situtation where it is possible for duplicate primary keys to occur in each table. I do not

Re: Duplicate Key in Db

2005-02-23 Thread Brandon Goodin
There is no way a framework would be able to accomplish that apart from exactly what you stated. You should assure the verasity of the object you want to insert before you attempt to insert it. That will always happen against the databsae even if you created a memory resident object identity layer.

Re: Duplicate Key in Db

2005-02-23 Thread Kris Jenkins
I'll get my coat... :-[ "The module code is a primary key and must be a unique value, though it must match with a value stored in another system so can not be an auto-increment value." I don't think his situation would allow for that. Brandon I'd want to design it so that the database assigns th

Re: Duplicate Key in Db

2005-02-23 Thread Brandon Goodin
"The module code is a primary key and must be a unique value, though it must match with a value stored in another system so can not be an auto-increment value." I don't think his situation would allow for that. Brandon > I'd want to design it so that the database assigns the primary keys. > It's

Re: Duplicate Key in Db

2005-02-23 Thread Kris Jenkins
Tim, I'd want to design it so that the database assigns the primary keys. It's the best way to do it IMHO. Any object to be persisted is checked for a primary key. If it's null, you do an insert; if it's not null, you want an update. The database assigns primary keys and can use a sequence

RE: Duplicate Key in Db

2005-02-23 Thread Akins, Greg
Can you perform the insert, and capture the error that comes back on the SQLException? -Original Message- From: Tim Christopher [mailto:[EMAIL PROTECTED] Sent: Wednesday, February 23, 2005 11:06 AM To: ibatis-user-java@incubator.apache.org Subject: Re: Duplicate Key in Db Sorry, I

Re: Duplicate Key in Db

2005-02-23 Thread Tim Christopher
Sorry, I should have mentioned that I was talking about an insertion... Currently it is possible for a user to create a new Module by specifying a module code, name, etc.. The module code is a primary key and must be a unique value, though it must match with a value stored in another system so ca

Re: Duplicate Key in Db

2005-02-23 Thread Brandon Goodin
you should not specify your primary key in the update values of your update statement. It should be part of your where criteria. BAD: UPDATE SOMETABLE (somePrimaryKey,columnA,columnB,columnC) VALUES(#somePrimaryKey#,#'valueA#,#valueB#,#valueC#) WHERE somePrimaryKey = 1 GOOD: UPDATE SOMETABLE (c