Using 3.0 and setting Java Type for RosterSlot the in the Modeller to a
boolean, then generating the classes, then getting rid of the extra
methods - fixed the problem.
One slightly strange thing I noticed. In the client version the
generated class is:
public boolean getMonthlyRestart()
,
but on the server version it is:
public boolean isMonthlyRestart()
Shouldn't the signatures be the same?
thanks - Chris
Andrus Adamchik wrote:
Can't say for sure what this is, but can you try it with 3.0?
BTW, 3.0 supports direct mapping of primitive booleans (boolean for
the ObjAttribute; BOOLEAN for the DbAttribute; TINYINT in MySQL)
Andrus
On Sep 30, 2008, at 8:10 AM, Chris Murphy wrote:
I have a problem that occurs when a fetch is done from the ROP
client, which causes the server to load client DOs using the values
from server DOs:
<
Can not set java.lang.Byte field
org.strandz.data.wombatrescue.objects.cayenne.client.auto._RosterSlot.monthlyRestart
to java.lang.Integer
>
I have checked that all the latest code and mapping information is on
the Tomcat server. The problem occurs when re-fetching a RosterSlot
that the client application created. What is interesting is that if I
reboot Tomcat then everything works as expected - showing that the
new RosterSlot did in fact make it successfully into the database. So
it is a ROP database refresh problem.
Is there anything else I need to check, or some easy way of debugging
this? _RosterSlot.monthlyRestart is a Byte variable in both client
and server versions of the DO. I do have methods on the subclasses
that serve to convert between Byte/Integer/boolean:
public boolean isMonthlyRestart()
{
boolean result = true;
if(getMonthlyRestart().intValue() == 0)
{
result = false;
}
return result;
}
public void setMonthlyRestart( boolean b)
{
if(b)
{
setMonthlyRestart( Utils.ONE.byteValue());
}
else
{
setMonthlyRestart( Utils.ZERO.byteValue());
}
}
From the Modeller I can see that MONTHLYRESTART is a TINYINT in the
MySql database and in the DO the Java Type is a Byte.
thanks - Chris
Some of the stack trace from the client:
org.apache.cayenne.CayenneRuntimeException: [v.2.0.4 October 8 2007]
Remote error. URL -
http://localhost:8080/cayenneRemoteService/cayenne-service; CAUSE -
Can not set java.lang.Byte field
org.strandz.data.wombatrescue.objects.cayenne.client.auto._RosterSlot.monthlyRestart
to java.lang.Integer
at
org.apache.cayenne.remote.hessian.HessianConnection.doSendMessage(HessianConnection.java:145)
at
org.apache.cayenne.remote.BaseConnection.sendMessage(BaseConnection.java:73)
at
org.apache.cayenne.remote.ClientChannel.send(ClientChannel.java:242)
at
org.apache.cayenne.remote.ClientChannel.onQuery(ClientChannel.java:88)
at
org.apache.cayenne.util.ObjectContextQueryAction.runQuery(ObjectContextQueryAction.java:217)
at
org.apache.cayenne.CayenneContextQueryAction.execute(CayenneContextQueryAction.java:47)
at org.apache.cayenne.CayenneContext.onQuery(CayenneContext.java:290)
at
org.apache.cayenne.CayenneContext.performQuery(CayenneContext.java:279)
at
org.apache.cayenne.util.RelationshipFault.resolveFromDB(RelationshipFault.java:90)
at
org.apache.cayenne.util.PersistentObjectList.resolvedObjectList(PersistentObjectList.java:299)
at
org.apache.cayenne.util.PersistentObjectList.iterator(PersistentObjectList.java:209)
at org.strandz.lgpl.extent.ActualList.iterator(ActualList.java:189)
Some of the stack trace from the server:
Caused by: java.lang.IllegalArgumentException: Can not set
java.lang.Byte field
org.strandz.data.wombatrescue.objects.cayenne.client.auto._RosterSlot.monthlyRestart
to java.lang.Integer
at
sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(UnsafeFieldAccessorImpl.java:146)
at
sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(UnsafeFieldAccessorImpl.java:150)
at
sun.reflect.UnsafeObjectFieldAccessorImpl.set(UnsafeObjectFieldAccessorImpl.java:63)
at java.lang.reflect.Field.set(Field.java:657)
at
org.apache.cayenne.property.FieldAccessor.writePropertyDirectly(FieldAccessor.java:79)
at
org.apache.cayenne.property.SimpleProperty.writePropertyDirectly(SimpleProperty.java:83)
at
org.apache.cayenne.property.SimpleProperty.writeProperty(SimpleProperty.java:54)
at
org.apache.cayenne.map.EntityDescriptor$SimplePersistentProperty.writeProperty(EntityDescriptor.java:305)
at
org.apache.cayenne.util.ObjectDetachOperation$1.visitProperty(ObjectDetachOperation.java:159)
at
org.apache.cayenne.property.SimpleProperty.visit(SimpleProperty.java:62)
at
org.apache.cayenne.property.BaseClassDescriptor.visitProperties(BaseClassDescriptor.java:214)
at
org.apache.cayenne.util.ObjectDetachOperation.detach(ObjectDetachOperation.java:98)
at
org.apache.cayenne.access.ClientServerChannelQueryAction.toClientObjects(ClientServerChannelQueryAction.java:185)
--
Seaweed Software Pty Ltd,
http://www.strandz.org
--
Seaweed Software Pty Ltd,
http://www.strandz.org