Hi Check!
One stone two birds. Thanks for you advice.
 I will set the same primary key for both person and Responsable.

Thanks!

On Sun, Jun 26, 2011 at 9:33 PM, Chuck Hill <[email protected]>wrote:

> Hi Fred,
>
>
> On Jun 26, 2011, at 6:28 PM, Fred Opims wrote:
>
> Hi Chuck!
>
> I found the problem! Entity Responsable is a subclass of Person entity. So
> Responsable had two primary keys : responsable_id and person_id.
>
>
> I think you are doing something wrong there in the model.  The superclass
> and subclasses all MUST have the same PK.  Responsable must use person_id as
>  the PK.  If you don't do that, EOF is going to be very, very confused.
>
>
> Chuck
>
>
>
>
> But the relationship was based only on responsable_id, that's  why i got
> the exception.
> To fix the problem, i have removed the constraint primary key on person_id
> and i kept it on responsable_id because i need  responsable_id to be set as
> primary key in postgresql database!
>
> Thank you for you light .
>
>
> On Sun, Jun 26, 2011 at 8:47 PM, Chuck Hill <[email protected]>wrote:
>
>> That sure looks  like a model problem.  It  could be that one of the plist
>> files is damaged.  Open up the plist files for the two related entities and
>> see if they contain what Entity Modeler is showing.
>>
>> Have you renamed any entities or attributes?
>>
>>
>>
>> Chuck
>>
>> On Jun 26, 2011, at 5:21 PM, Fred Opims wrote:
>>
>> Hi Chuck!
>> Thank you for the quick response! .
>>
>> I made sure that Responsable primary Key is the Vehicule foreign Key and i
>> have validated the model.
>>
>> Here is the stack trace
>>
>> Jun 26 20:17:15 TicketManagmentServer[54345] WARN
>> er.extensions.eof.ERXModelGroup  - Clearing previous class descriptions
>> Jun 26 20:17:15 TicketManagmentServer[54345] WARN
>> er.extensions.eof.ERXModelGroup  - The EOModel 'erprototypes' has an empty
>> connection dictionary.
>> Jun 26 20:17:15 TicketManagmentServer[54345] WARN
>> er.extensions.eof.ERXModelGroup  - The EOModel 'erprototypes' has an empty
>> connection dictionary.
>> Jun 26 20:17:16 TicketManagmentServer[54345] DEBUG NSLog  - Using
>> JDBCPlugIn 'com.webobjects.jdbcadaptor.PostgresqlPlugIn' for JDBCAdaptor@
>> 2019733318
>> Jun 26 20:17:16 TicketManagmentServer[54345] DEBUG NSLog  - Using
>> JDBCPlugIn 'com.webobjects.jdbcadaptor.PostgresqlPlugIn' for
>> JDBCAdaptor@1901677475
>> Jun 26 20:17:16 TicketManagmentServer[54345] DEBUG NSLog  -  connecting
>> with dictionary: {plugin = "Postgresql"; username = "postgres"; driver =
>> "org.postgresql.Driver"; password = "<password deleted for log>"; URL =
>> "jdbc:postgresql://localhost/TicketManagment"; }
>> Jun 26 20:17:16 TicketManagmentServer[54345] DEBUG NSLog  - fetching JDBC
>> Info with JDBCContext@1433183189
>> Jun 26 20:17:16 TicketManagmentServer[54345] DEBUG NSLog  -  connecting
>> with dictionary: {plugin = "Postgresql"; username = "postgres"; driver =
>> "org.postgresql.Driver"; password = "<password deleted for log>"; URL =
>> "jdbc:postgresql://localhost/TicketManagment"; }
>> Jun 26 20:17:16 TicketManagmentServer[54345] DEBUG NSLog  -  === Begin
>> Internal Transaction
>> Jun 26 20:17:16 TicketManagmentServer[54345] DEBUG NSLog  -
>> evaluateExpression: <com.webobjects.jdbcadaptor.PostgresqlExpression:
>> "SELECT t0.annee, t0.couleur, t0.immatriculation, t0.marque, t0.modele,
>> t0.numero_serie, t0.responsable_id, t0.statut_id, t0.sujet_id, t0.type FROM
>> Vehicule t0 WHERE t0.immatriculation like ?::text ESCAPE '|' ORDER BY
>> t0.immatriculation ASC" withBindings: 1:"667PTS"(immatriculation)>
>> Jun 26 20:17:16 TicketManagmentServer[54345] DEBUG NSLog  - 1 row(s)
>> processed
>> Jun 26 20:17:16 TicketManagmentServer[54345] DEBUG NSLog  -  === Commit
>> Internal Transaction
>> Jun 26 20:17:16 TicketManagmentServer[54345] WARN  NSLog  -
>> <com.opsoft.tms.app.DirectAction>: Exception in performActionNamed() on the
>> action "HandleNewCreatedTicket" with the message:
>> java.lang.NullPointerException
>> Jun 26 20:17:16 TicketManagmentServer[54345] ERROR
>> er.directtoweb.ERD2WDirectAction  - Error with action
>> HandleNewCreatedTicket:java.lang.NullPointerException,
>> formValues:{createTicket = (""); imageData.mimetype =
>> ("application/octet-stream"); imageData = (<class
>> com.webobjects.appserver._private.WOInputStreamData (offset=0, length=768,
>> data=[60]'<', [63]'?', [120]'x', [109]'m', [108]'l', [32]' ', [118]'v',
>> [101]'e', [114]'r', [115]'s', [105]'i', [111]'o', [110]'n', [61]'=',
>> [34]'"', [49]'1', [46]'.', [48]'0', [34]'"', [32]' ', [101]'e', [110]'n',
>> [99]'c', [111]'o', [100]'d', [105]'i', [110]'n', [103]'g', [61]'=',
>> [34]'"'...)>); imageData.filename = ("ticket.plist"); }
>> NullPointerException
>>   at
>> com.webobjects.eoaccess.EODatabaseContext._objectFaultWithSnapshotRelationshipEditingContext(EODatabaseContext.java:2356)
>>      ... skipped 1 stack elements
>>   at
>> com.webobjects.eoaccess.EOAccessDeferredFaultHandler.createFaultForDeferredFault(EOAccessDeferredFaultHandler.java:49)
>>   at
>> com.webobjects.eocontrol.EOCustomObject.willReadRelationship(EOCustomObject.java:1279)
>>   at
>> er.extensions.eof.ERXGenericRecord.willReadRelationship(ERXGenericRecord.java:409)
>>   at
>> com.webobjects.eocontrol._EOMutableKnownKeyDictionary$Initializer$_LazyGenericRecordBinding.valueInObject(_EOMutableKnownKeyDictionary.java:614)
>>   at
>> er.extensions.eof.ERXGenericRecord$TouchingBinding.valueInObject(ERXGenericRecord.java:205)
>>   at
>> com.webobjects.eocontrol.EOCustomObject.storedValueForKey(EOCustomObject.java:1634)
>>   at com.opsoft.tms._Vehicule.responsable(_Vehicule.java:93)
>>   at com.opsoft.tms.Vehicule.responsable(Vehicule.java:11)
>>   at
>> com.opsoft.tms.app.DirectAction.getDictionaryFromVehicule(DirectAction.java:400)
>>   at
>> com.opsoft.tms.app.DirectAction.vehiculesFromImmatriculation(DirectAction.java:380)
>>   at
>> com.opsoft.tms.app.DirectAction.HandleNewCreatedTicketAction(DirectAction.java:183)
>>      ... skipped 4 stack elements
>>   at
>> com.webobjects.appserver.WODirectAction.performActionNamed(WODirectAction.java:144)
>>   at
>> er.extensions.appserver.ERXDirectAction.performActionNamed(ERXDirectAction.java:401)
>>   at
>> er.directtoweb.ERD2WDirectAction.performActionNamed(ERD2WDirectAction.java:449)
>>   ... skipped 9 stack elements
>>
>>
>> On Sun, Jun 26, 2011 at 8:12 PM, Chuck Hill <[email protected]>wrote:
>>
>>> Hi Fred,
>>>
>>>
>>> On Jun 26, 2011, at 5:01 PM, Fred Opims wrote:
>>>
>>> > Hi!
>>> > I have some problem to a to-one relationship.
>>> > I have an Entity with 3 properties ( color, brand, model) and one
>>> relationship Responsable,
>>> >
>>> > When i make a fetch, i'm able to access to all propeties, but i can't
>>> access to relation responsable.
>>> > Here is the code
>>> >
>>> >         String imm = vehicule.immatriculation();  //Access OK
>>> >         String marque = vehicule.marque(); //Access OK
>>> >         String modele = vehicule.modele(); //Access OK
>>> >
>>> > When i do
>>> >     Responsable resp = vehicule.responsable(); i have a
>>> _objectFaultWithSnapshotRelationshipEditingContext exception.
>>>
>>> That sounds like you have a problem with data consistency in your
>>> database.  Turn on SQL logging (launch with -DEOAdaptorDebugEnabled=true).
>>>
>>> Or your model is wrong.  Can you post the entire exception message and
>>> stack trace?
>>>
>>> You should very, very rarely need to use willRead and
>>> willReadRelationship for anything. You should not be using it here.
>>>
>>>
>>> Chuck
>>>
>>>
>>>
>>> >
>>> > In the WebObject Entreprise Objects Programming Guide, it is written
>>> that the fault is fired when the relationship's data is needed.
>>> >
>>> > But when i do the following, i still have the same
>>> _objectFaultWithSnapshotRelationshipEditingContext exception.
>>> >
>>> >         String name= vehicule.responsable().name();
>>> >         String firstname= vehicule.responsable().firstname();
>>> >
>>> > It is also written to call willRead() before accessing to the
>>> relationship's data.
>>> >
>>> > So i did:
>>> >           vehicule.willRead();
>>> >             String name= vehicule.responsable().name();
>>> >         String firstname= vehicule.responsable().firstname();
>>> >
>>> > But it doesn't work. Same exception
>>> >
>>> > After that, in Vehicule.java i did the following as suggested in the
>>> doc:
>>> >
>>> > public class Vehicule extends _Vehicule {
>>> >     @SuppressWarnings("unused")
>>> >     private static Logger log = Logger.getLogger(Vehicule.class);
>>> >
>>> >      public com.package.Responsable responsable() {
>>> >          willRead();
>>> >             return super.responsable();
>>> >      }
>>> >
>>> >         public static boolean usesDeferredFaultCreation() {
>>> >
>>> >             return true;
>>> >
>>> >         }
>>> > }
>>> >
>>> > I made sure the my model is valid and that data in the database are
>>> well set.
>>> >
>>> > Can you tell me please if i'm using willRead the right way? How can i
>>> access to this relationship?
>>> >
>>> > Thank you very much!
>>> >
>>> > Fred
>>> > _______________________________________________
>>> > Do not post admin requests to the list. They will be ignored.
>>> > Webobjects-dev mailing list      ([email protected])
>>> > Help/Unsubscribe/Update your Subscription:
>>> >
>>> http://lists.apple.com/mailman/options/webobjects-dev/chill%40global-village.net
>>> >
>>> > This email sent to [email protected]
>>>
>>> --
>>> Chuck Hill             Senior Consultant / VP Development
>>>
>>> Come to WOWODC this July for unparalleled WO learning opportunities and
>>> real peer to peer problem solving!  Network, socialize, and enjoy a great
>>> cosmopolitan city.  See you there!  http://www.wocommunity.org/wowodc11/
>>>
>>>
>>
>> --
>>
>> Chuck Hill             Senior Consultant / VP Development
>>
>> Come to WOWODC this July for unparalleled WO learning opportunities and
>> real peer to peer problem solving!  Network, socialize, and enjoy a great
>> cosmopolitan city.  See you there!  http://www.wocommunity.org/wowodc11/
>>
>>
>
> --
>
> Chuck Hill             Senior Consultant / VP Development
>
> Come to WOWODC this July for unparalleled WO learning opportunities and
> real peer to peer problem solving!  Network, socialize, and enjoy a great
> cosmopolitan city.  See you there!  http://www.wocommunity.org/wowodc11/
>
>
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      ([email protected])
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com

This email sent to [email protected]

Reply via email to