[
https://issues.apache.org/cayenne/browse/CAY-483?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Andrey Razumovsky closed CAY-483.
---------------------------------
Resolution: Incomplete
Fix Version/s: 3.0M6
Closing this. Methods of this issue are deprecated or do not exist. Improved
throwing was added to couple of places, and any other sutiations need futher
discussion.
> Improved error reporting for Newbie error
> -----------------------------------------
>
> Key: CAY-483
> URL: https://issues.apache.org/cayenne/browse/CAY-483
> Project: Cayenne
> Issue Type: Improvement
> Components: Cayenne Core Library
> Affects Versions: 1.2 branch
> Environment: Cayenne 1.2M9, Windows XP, JDK 1.4.2_09
> Reporter: Malcolm Edgar
> Assignee: Andrey Razumovsky
> Fix For: 3.0M6
>
>
> Being a Cayenne newbie, I started to build an object graph attempting to
> attach new DataObjects created using the new keyword, rather that using:
> DataContext.createAndRegisterNewObject(Class)
> When I attempted to attach to new objects to form a relationship, an NPE
> occured in CayenneDataContext, as the dataContext was not initialized.
> private ObjRelationship getRelationshipNamed(String relName) {
> return (ObjRelationship) dataContext
> .getEntityResolver()
> .lookupObjEntity(this)
> .getRelationship(relName);
> }
> It was not immediately obvious to me what the error was, after breakpointing
> the code in a debugging and thinking about it it made more sense. However I
> think it would be good if this method had an assertion before attempting to
> lookup the entity resolver, e.g
> private ObjRelationship getRelationshipNamed(String relName) {
> if (dataContext == null) {
> String msg =
> getClass().getName() + " relationship " + relName
> + " cannot be determined as the dataContext is"
> + " not initialized";
> new IllegalStateException(msg);
> }
> return (ObjRelationship) dataContext
> .getEntityResolver()
> .lookupObjEntity(this)
> .getRelationship(relName);
> }
> regards Malcolm Edgar
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.