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/
smime.p7s
Description: S/MIME cryptographic signature
_______________________________________________ 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]
