Re: Optimistick locking problem
Re: Optimistick locking problem
- Subject: Re: Optimistick locking problem
- From: Marcos Trejo Munguia <email@hidden>
- Date: Tue, 13 Sep 2005 19:44:43 -0500
Thank you for your help Chuck, I will try the second option (run the
SQL in the SQL Interpreter) to figure out what's wrong with the SQL,
and thank you for the advice with primary keys, unfortunately I cannot
change the database because it belongs to another system(not mine). I
will tell you if this works or not.
On Sep 13, 2005, at 4:27 PM, Chuck Hill wrote:
That is odd. FWIW, I have often found trailing spaces to cause
various problems. In your EOModel, articulo is defined as
{
columnName = Articulo;
externalType = char;
name = articulo;
valueClassName = NSString;
valueType = c;
width = 20;
},
So it seems to be expecting a fixed width, 20 character string. Using
varchar for this and getting rid of the trailing spaces is probably
your best option. Otherwise, try running the SQL below in an SQL
interpreter and see what you have to do (probably adding spaces) to
get it to work right. Then you can work backwards and figure out what
EOF is not generating correctly.
And while I am on the topic, user meaningful primary keys are not what
I would recommend. Sooner or later you will have to change one and
EOF won't like and won't allow it.
Chuck
On Sep 13, 2005, at 2:17 PM, Marcos Trejo Munguia wrote:
I also though that the spaces could be the problem, so I had changed
the value type of articulo to S that doesn't make RTRIM when the
fetch occur, but the results were the same(the exception is still
there), here is the SQL generated:
"UPDATE dbo.Art SET Tipo = ? WHERE Articulo = ?" withBindings:
1:"Luminaria"(tipo), 2:"1N-748-T "(articulo)
I looked at the database and the data is exactly like above("1N-748-T
") with all the spaces, so I think it might be another
problem.
On Sep 13, 2005, at 2:18 PM, Chuck Hill wrote:
How did the data get into the database? Does 2:"1N-748-T"(articulo)
have any spaces before or after when you look directly at the
database. Things like "1N-748-T " (notice the space after T) can
cause this.
Chuck
On Sep 13, 2005, at 10:17 AM, Marcos Trejo Munguia wrote:
Hi list:
I'm using WebObjects 5.2.3 on Mac OS X 10.3.9 and the database
MSSQL Server 2000 on a Windows NT Machine.
I get the next exception when I try to update a row:
Error: com.webobjects.eoaccess.EOGeneralAdaptorException:
updateValuesInRowDescribedByQualifier --
com.webobjects.jdbcadaptor.JDBCChannel method failed to update row
in database
Reason: updateValuesInRowDescribedByQualifier --
com.webobjects.jdbcadaptor.JDBCChannel method failed to update row
in database
Stack trace:
File Line# Method Package
EODatabaseContext.java 4676
_exceptionWithDatabaseContextInformationAdded
com.webobjects.eoaccess
EODatabaseContext.java 6384 performChanges
com.webobjects.eoaccess
EOObjectStoreCoordinator.java 415
saveChangesInEditingContext com.webobjects.eocontrol
EOEditingContext.java 3165 saveChanges
com.webobjects.eocontrol
Main.java 24 <init> Main
NativeConstructorAccessorImpl.java NA newInstance0
sun.reflect
NativeConstructorAccessorImpl.java 39 newInstance
sun.reflect
DelegatingConstructorAccessorImpl.java 27 newInstance
sun.reflect
Constructor.java 274 newInstance java.lang.reflect
_NSUtilities.java 575 instantiateObject
com.webobjects.foundation
WOComponentDefinition.java 463 _componentInstanceInContext
com.webobjects.appserver._private
WOComponentDefinition.java 573 componentInstanceInContext
com.webobjects.appserver._private
WOApplication.java 1954 pageWithName
com.webobjects.appserver
WOComponentRequestHandler.java 273
_dispatchWithPreparedSession com.webobjects.appserver._private
WOComponentRequestHandler.java 322
_dispatchWithPreparedApplication
com.webobjects.appserver._private
WOComponentRequestHandler.java 358 _handleRequest
com.webobjects.appserver._private
WOComponentRequestHandler.java 432 handleRequest
com.webobjects.appserver._private
WOApplication.java 1306 dispatchRequest
com.webobjects.appserver
WOWorkerThread.java 173 runOnce
com.webobjects.appserver._private
WOWorkerThread.java 254 run
com.webobjects.appserver._private
Thread.java 552 run java.lang
The code that throws the exception:
EOEditingContext ec = new EOEditingContext();
EOFetchSpecification fs = new
EOFetchSpecification("Articulo", null, null, true, false, null);
fs.setRefreshesRefetchedObjects(true);
fs.setFetchLimit(1);
Articulo articulo = (Articulo)
ec.objectsWithFetchSpecification(fs).lastObject();
articulo.setTipo("Luminaria");
ec.saveChanges();
and the SQL generated:
"UPDATE dbo.Art SET Tipo = ? WHERE Articulo = ?" withBindings:
1:"Luminaria"(tipo), 2:"1N-748-T"(articulo)
My model looks like this:
{
attributes = (
{
columnName = Accesorios;
externalType = bit;
name = accesorios;
precision = 1;
valueClassName = NSNumber;
valueType = i;
},
{
columnName = Articulo;
externalType = char;
name = articulo;
valueClassName = NSString;
valueType = c;
width = 20;
},
{
columnName = Conciliar;
externalType = bit;
name = conciliar;
precision = 1;
valueClassName = NSNumber;
valueType = i;
},
{
columnName = Estatus;
externalType = char;
name = estatus;
valueClassName = NSString;
valueType = c;
width = 15;
},
{
columnName = Impuesto1;
externalType = float;
name = impuesto1;
precision = 53;
valueClassName = NSNumber;
valueType = f;
},
{
columnName = MonedaCosto;
externalType = char;
name = monedacosto;
valueClassName = NSString;
valueType = c;
width = 10;
},
{
columnName = MonedaPrecio;
externalType = char;
name = monedaprecio;
valueClassName = NSString;
valueType = c;
width = 10;
},
{
columnName = ProdOpciones;
externalType = bit;
name = prodopciones;
precision = 1;
valueClassName = NSNumber;
valueType = i;
},
{
columnName = Refacciones;
externalType = bit;
name = refacciones;
precision = 1;
valueClassName = NSNumber;
valueType = i;
},
{
columnName = Refrigeracion;
externalType = bit;
name = refrigeracion;
precision = 1;
valueClassName = NSNumber;
valueType = i;
},
{
columnName = SeProduce;
externalType = bit;
name = seproduce;
precision = 1;
valueClassName = NSNumber;
valueType = i;
},
{
columnName = Sustitutos;
externalType = bit;
name = sustitutos;
precision = 1;
valueClassName = NSNumber;
valueType = i;
},
{
columnName = TieneCaducidad;
externalType = bit;
name = tienecaducidad;
precision = 1;
valueClassName = NSNumber;
valueType = i;
},
{
columnName = Tipo;
externalType = varchar;
name = tipo;
valueClassName = NSString;
valueType = S;
width = 20;
},
{
columnName = TipoOpcion;
externalType = varchar;
name = tipoopcion;
valueClassName = NSString;
valueType = S;
width = 20;
}
);
attributesUsedForLocking = (articulo);
className = Articulo;
classProperties = (
impuesto1,
tipo,
tipoopcion,
accesorios,
refacciones,
sustitutos,
monedacosto,
monedaprecio,
estatus,
conciliar,
refrigeracion,
tienecaducidad,
seproduce,
prodopciones
);
externalName = "dbo.Art";
fetchSpecificationDictionary = {};
name = Articulo;
primaryKeyAttributes = (articulo);
}
As you can see I'm locking on a String with value type c, I'm not
sure what the problem is and how to fix it, please somebody help
me, I'll appreciate your help.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
email@hidden
This email sent to email@hidden
--
Practical WebObjects - a book for intermediate WebObjects developers
who want to increase their overall knowledge of WebObjects, or those
who are trying to solve specific application development problems.
http://www.global-village.net/products/practical_webobjects
--
Practical WebObjects - a book for intermediate WebObjects developers
who want to increase their overall knowledge of WebObjects, or those
who are trying to solve specific application development problems.
http://www.global-village.net/products/practical_webobjects
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden