• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: JavaEOGenerator running, but I do not understand the output.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: JavaEOGenerator running, but I do not understand the output.


  • Subject: Re: JavaEOGenerator running, but I do not understand the output.
  • From: Johan Henselmans <email@hidden>
  • Date: Mon, 12 Nov 2007 12:49:46 +0100


Op 11 nov 2007, om 17:40 heeft Mike Schrag het volgende geschreven:

After I made all the classes part of a package, everything was fine, apart from the fact that they were 5.4-ish, and I want 5.3. So I went to the second EOGenerator solution,
You can use JavaEOGenerator to produce 5.3 classes -- you just need to modify the templates to not use 5.4 features.

I tried that, but there are some strange things: if there is no class definition, eg it is just EOGenericRecord, it will create a class EOGenericRecord, and _EOGenericRecord, or com.webobjects.eocontrol.EOGenericRecord, depending on how the thing is defined in the EOModel.
I don't ever use EOGenericRecord classes, but I thought that if you wanted this, that you should leave the class names blank in the entity definition.

Also, it seems that there are some strange things going on with n:m relations.

For instance, I have an n:m relation between product and review, so there is a connection table reviewproduct, with a class RevIewProduct.

Now I get an error in Product in this statement:

EOQualifier inverseQualifier = new EOKeyValueQualifier(nl.immix.ReviewProduct.PRODUCT_KEY, EOQualifier.QualifierOperatorEqual, this);

with the error:
	nl.immix.ReviewProduct.PRODUCT_KEY cannot be resolved	

which i scompletely logical as there is nno PRODUCT_KEY in the ReviewProduct class.
Not sure I follow ... If you are expecting to be able to access ReviewProduct.product(), you will need to make a class relationship named "product" on your join class. You can't qualify on a non- class relationship. If it was a class relationship, then the templates would produce a PRODUCT_KEY for you.


Sorry for the confusion:

Perhaps some pictures and source code will make it clearer (I hope)

The model has a n:m relation from review to product, so I'd there is a table reviewproduct that only contains the id's of a review and the id of a product. that translates in EOModeler to such a construction:


PNG image



With Review Product being just a table in between.

PNG image



The source code of _ReviewProduct, however does not define PRODUCT_KEY, nor REVIEW_KEY:


===================== // DO NOT EDIT. Make changes to ReviewProduct.java instead. package nl.immix;

import com.webobjects.eoaccess.*;
import com.webobjects.eocontrol.*;
import com.webobjects.foundation.*;
import java.math.*;
import java.util.*;
import org.apache.log4j.Logger;

@SuppressWarnings("all")
public abstract class _ReviewProduct extends  EOGenericRecord {
	public static final String ENTITY_NAME = "ReviewProduct";

	// Attributes

	// Relationships

  private static Logger LOG = Logger.getLogger(_ReviewProduct.class);

public ReviewProduct localInstanceOfReviewProduct(EOEditingContext editingContext) {
ReviewProduct localInstance = (ReviewProduct)EOUtilities.localInstanceOfObject(editingContext, this);
if (localInstance == null) {
throw new IllegalStateException("You attempted to localInstance " + this + ", which has not yet committed.");
}
return localInstance;
}


  public nl.immix.Product product() {
    return (nl.immix.Product)storedValueForKey("product");
  }

public void setProductRelationship(nl.immix.Product value) {
if (_ReviewProduct.LOG.isDebugEnabled()) {
_ReviewProduct.LOG.debug("updating product from " + product() + " to " + value);
}
if (value == null) {
nl.immix.Product oldValue = product();
if (oldValue != null) {
removeObjectFromBothSidesOfRelationshipWithKey(oldValue, "product");
}
} else {
addObjectToBothSidesOfRelationshipWithKey(value, "product");
}
}


  public nl.immix.Review review() {
    return (nl.immix.Review)storedValueForKey("review");
  }

public void setReviewRelationship(nl.immix.Review value) {
if (_ReviewProduct.LOG.isDebugEnabled()) {
_ReviewProduct.LOG.debug("updating review from " + review() + " to " + value);
}
if (value == null) {
nl.immix.Review oldValue = review();
if (oldValue != null) {
removeObjectFromBothSidesOfRelationshipWithKey(oldValue, "review");
}
} else {
addObjectToBothSidesOfRelationshipWithKey(value, "review");
}
}


public static ReviewProduct createReviewProduct(EOEditingContext editingContext) {
ReviewProduct eo = (ReviewProduct)EOUtilities.createAndInsertInstance(editingContext, _ReviewProduct.ENTITY_NAME);
return eo;
}


public static NSArray<ReviewProduct> fetchAllReviewProducts(EOEditingContext editingContext) {
return _ReviewProduct.fetchAllReviewProducts(editingContext, null);
}


public static NSArray<ReviewProduct> fetchAllReviewProducts(EOEditingContext editingContext, NSArray<EOSortOrdering> sortOrderings) {
return _ReviewProduct.fetchReviewProducts(editingContext, null, sortOrderings);
}


public static NSArray<ReviewProduct> fetchReviewProducts(EOEditingContext editingContext, EOQualifier qualifier, NSArray<EOSortOrdering> sortOrderings) {
EOFetchSpecification fetchSpec = new EOFetchSpecification(_ReviewProduct.ENTITY_NAME, qualifier, sortOrderings);
fetchSpec.setIsDeep(true);
NSArray<ReviewProduct> eoObjects = (NSArray <ReviewProduct>)editingContext.objectsWithFetchSpecification(fetchSpec);
return eoObjects;
}


public static ReviewProduct fetchReviewProduct(EOEditingContext editingContext, String keyName, Object value) {
return _ReviewProduct.fetchReviewProduct(editingContext, new EOKeyValueQualifier(keyName, EOQualifier.QualifierOperatorEqual, value));
}


public static ReviewProduct fetchReviewProduct(EOEditingContext editingContext, EOQualifier qualifier) {
NSArray<ReviewProduct> eoObjects = _ReviewProduct.fetchReviewProducts(editingContext, qualifier, null);
ReviewProduct eoObject;
int count = eoObjects.count();
if (count == 0) {
eoObject = null;
}
else if (count == 1) {
eoObject = (ReviewProduct)eoObjects.objectAtIndex(0);
}
else {
throw new IllegalStateException("There was more than one ReviewProduct that matched the qualifier '" + qualifier + "'.");
}
return eoObject;
}


public static ReviewProduct fetchRequiredReviewProduct(EOEditingContext editingContext, String keyName, Object value) {
return _ReviewProduct.fetchRequiredReviewProduct(editingContext, new EOKeyValueQualifier(keyName, EOQualifier.QualifierOperatorEqual, value));
}


public static ReviewProduct fetchRequiredReviewProduct(EOEditingContext editingContext, EOQualifier qualifier) {
ReviewProduct eoObject = _ReviewProduct.fetchReviewProduct(editingContext, qualifier);
if (eoObject == null) {
throw new NoSuchElementException("There was no ReviewProduct that matched the qualifier '" + qualifier + "'.");
}
return eoObject;
}


public static ReviewProduct localInstanceOfReviewProduct(EOEditingContext editingContext, ReviewProduct eo) {
ReviewProduct localInstance = (eo == null) ? null : (ReviewProduct)EOUtilities.localInstanceOfObject(editingContext, eo);
if (localInstance == null && eo != null) {
throw new IllegalStateException("You attempted to localInstance " + eo + ", which has not yet committed.");
}
return localInstance;
}
}
===============================


Which causes the statement in Review
EOQualifier inverseQualifier = new EOKeyValueQualifier(nl.immix.ReviewProduct.PRODUCT_KEY, EOQualifier.QualifierOperatorEqual, this);


to be unsolvable:


=============================== // DO NOT EDIT. Make changes to Review.java instead. package nl.immix;

import com.webobjects.eoaccess.*;
import com.webobjects.eocontrol.*;
import com.webobjects.foundation.*;
import java.math.*;
import java.util.*;
import org.apache.log4j.Logger;

@SuppressWarnings("all")
public abstract class _Review extends  EOGenericRecord {
	public static final String ENTITY_NAME = "Review";

// Attributes
public static final String REVIEW_DATE_EDITED_KEY = "reviewDateEdited";
public static final String REVIEW_DATE_EMBARGO_KEY = "reviewDateEmbargo";
public static final String REVIEW_TEXT_KEY = "reviewText";
public static final String REVIEW_TIME_EMBARGO_KEY = "reviewTimeEmbargo";
public static final String REVIEW_TITLE_KEY = "reviewTitle";


	// Relationships
	public static final String EDITOR_KEY = "editor";
	public static final String PRODUCTS_KEY = "products";

  private static Logger LOG = Logger.getLogger(_Review.class);

public Review localInstanceOfReview(EOEditingContext editingContext) {
Review localInstance = (Review)EOUtilities.localInstanceOfObject(editingContext, this);
if (localInstance == null) {
throw new IllegalStateException("You attempted to localInstance " + this + ", which has not yet committed.");
}
return localInstance;
}


  public NSTimestamp reviewDateEdited() {
    return (NSTimestamp) storedValueForKey("reviewDateEdited");
  }

public void setReviewDateEdited(NSTimestamp value) {
if (_Review.LOG.isDebugEnabled()) {
_Review.LOG.debug( "updating reviewDateEdited from " + reviewDateEdited() + " to " + value);
}
takeStoredValueForKey(value, "reviewDateEdited");
}


  public NSTimestamp reviewDateEmbargo() {
    return (NSTimestamp) storedValueForKey("reviewDateEmbargo");
  }

public void setReviewDateEmbargo(NSTimestamp value) {
if (_Review.LOG.isDebugEnabled()) {
_Review.LOG.debug( "updating reviewDateEmbargo from " + reviewDateEmbargo() + " to " + value);
}
takeStoredValueForKey(value, "reviewDateEmbargo");
}


  public String reviewText() {
    return (String) storedValueForKey("reviewText");
  }

public void setReviewText(String value) {
if (_Review.LOG.isDebugEnabled()) {
_Review.LOG.debug( "updating reviewText from " + reviewText() + " to " + value);
}
takeStoredValueForKey(value, "reviewText");
}


  public NSTimestamp reviewTimeEmbargo() {
    return (NSTimestamp) storedValueForKey("reviewTimeEmbargo");
  }

public void setReviewTimeEmbargo(NSTimestamp value) {
if (_Review.LOG.isDebugEnabled()) {
_Review.LOG.debug( "updating reviewTimeEmbargo from " + reviewTimeEmbargo() + " to " + value);
}
takeStoredValueForKey(value, "reviewTimeEmbargo");
}


  public String reviewTitle() {
    return (String) storedValueForKey("reviewTitle");
  }

public void setReviewTitle(String value) {
if (_Review.LOG.isDebugEnabled()) {
_Review.LOG.debug( "updating reviewTitle from " + reviewTitle() + " to " + value);
}
takeStoredValueForKey(value, "reviewTitle");
}


  public nl.immix.Employee editor() {
    return (nl.immix.Employee)storedValueForKey("editor");
  }

public void setEditorRelationship(nl.immix.Employee value) {
if (_Review.LOG.isDebugEnabled()) {
_Review.LOG.debug("updating editor from " + editor() + " to " + value);
}
if (value == null) {
nl.immix.Employee oldValue = editor();
if (oldValue != null) {
removeObjectFromBothSidesOfRelationshipWithKey(oldValue, "editor");
}
} else {
addObjectToBothSidesOfRelationshipWithKey(value, "editor");
}
}


  public NSArray<nl.immix.Product> products() {
    return (NSArray<nl.immix.Product>)storedValueForKey("products");
  }

  public NSArray<nl.immix.Product> products(EOQualifier qualifier) {
    return products(qualifier, null);
  }

public NSArray<nl.immix.Product> products(EOQualifier qualifier, NSArray<EOSortOrdering> sortOrderings) {
NSArray<nl.immix.Product> results;
results = products();
if (qualifier != null) {
results = (NSArray <nl.immix.Product>)EOQualifier.filteredArrayWithQualifier(results, qualifier);
}
if (sortOrderings != null) {
results = (NSArray < nl .immix.Product>)EOSortOrdering.sortedArrayUsingKeyOrderArray(results, sortOrderings);
}
return results;
}


public void addToProductsRelationship(nl.immix.Product object) {
if (_Review.LOG.isDebugEnabled()) {
_Review.LOG.debug("adding " + object + " to products relationship");
}
addObjectToBothSidesOfRelationshipWithKey(object, "products");
}


public void removeFromProductsRelationship(nl.immix.Product object) {
if (_Review.LOG.isDebugEnabled()) {
_Review.LOG.debug("removing " + object + " from products relationship");
}
removeObjectFromBothSidesOfRelationshipWithKey(object, "products");
}


public nl.immix.Product createProductsRelationship() {
EOClassDescription eoClassDesc = EOClassDescription.classDescriptionForEntityName("Product");
EOEnterpriseObject eo = eoClassDesc.createInstanceWithEditingContext(editingContext(), null);
editingContext().insertObject(eo);
addObjectToBothSidesOfRelationshipWithKey(eo, "products");
return (nl.immix.Product) eo;
}


  public void deleteProductsRelationship(nl.immix.Product object) {
    removeObjectFromBothSidesOfRelationshipWithKey(object, "products");
    editingContext().deleteObject(object);
  }

public void deleteAllProductsRelationships() {
Enumeration objects = products().immutableClone().objectEnumerator();
while (objects.hasMoreElements()) {
deleteProductsRelationship((nl.immix.Product)objects.nextElement());
}
}


public NSArray<nl.immix.ReviewProduct> reviewProducts() {
return (NSArray<nl.immix.ReviewProduct>)storedValueForKey("reviewProducts");
}


public NSArray<nl.immix.ReviewProduct> reviewProducts(EOQualifier qualifier) {
return reviewProducts(qualifier, null, false);
}


public NSArray<nl.immix.ReviewProduct> reviewProducts(EOQualifier qualifier, boolean fetch) {
return reviewProducts(qualifier, null, fetch);
}


public NSArray<nl.immix.ReviewProduct> reviewProducts(EOQualifier qualifier, NSArray<EOSortOrdering> sortOrderings, boolean fetch) {
NSArray<nl.immix.ReviewProduct> results;
if (fetch) {
EOQualifier fullQualifier;
EOQualifier inverseQualifier = new EOKeyValueQualifier(nl.immix.ReviewProduct.REVIEW_KEY, EOQualifier.QualifierOperatorEqual, this);
if (qualifier == null) {
fullQualifier = inverseQualifier;
}
else {
NSMutableArray qualifiers = new NSMutableArray();
qualifiers.addObject(qualifier);
qualifiers.addObject(inverseQualifier);
fullQualifier = new EOAndQualifier(qualifiers);
}
results = nl.immix.ReviewProduct.fetchReviewProducts(editingContext(), fullQualifier, sortOrderings);
}
else {
results = reviewProducts();
if (qualifier != null) {
results = (NSArray < nl .immix.ReviewProduct>)EOQualifier.filteredArrayWithQualifier(results, qualifier);
}
if (sortOrderings != null) {
results = (NSArray < nl .immix .ReviewProduct>)EOSortOrdering.sortedArrayUsingKeyOrderArray(results, sortOrderings);
}
}
return results;
}


public void addToReviewProductsRelationship(nl.immix.ReviewProduct object) {
if (_Review.LOG.isDebugEnabled()) {
_Review.LOG.debug("adding " + object + " to reviewProducts relationship");
}
addObjectToBothSidesOfRelationshipWithKey(object, "reviewProducts");
}


public void removeFromReviewProductsRelationship(nl.immix.ReviewProduct object) {
if (_Review.LOG.isDebugEnabled()) {
_Review.LOG.debug("removing " + object + " from reviewProducts relationship");
}
removeObjectFromBothSidesOfRelationshipWithKey(object, "reviewProducts");
}


public nl.immix.ReviewProduct createReviewProductsRelationship() {
EOClassDescription eoClassDesc = EOClassDescription.classDescriptionForEntityName("ReviewProduct");
EOEnterpriseObject eo = eoClassDesc.createInstanceWithEditingContext(editingContext(), null);
editingContext().insertObject(eo);
addObjectToBothSidesOfRelationshipWithKey(eo, "reviewProducts");
return (nl.immix.ReviewProduct) eo;
}


public void deleteReviewProductsRelationship(nl.immix.ReviewProduct object) {
removeObjectFromBothSidesOfRelationshipWithKey(object, "reviewProducts");
editingContext().deleteObject(object);
}


public void deleteAllReviewProductsRelationships() {
Enumeration objects = reviewProducts().immutableClone().objectEnumerator();
while (objects.hasMoreElements()) {
deleteReviewProductsRelationship ((nl.immix.ReviewProduct)objects.nextElement());
}
}


public static Review createReview(EOEditingContext editingContext, nl.immix.Employee editor) {
Review eo = (Review)EOUtilities.createAndInsertInstance(editingContext, _Review.ENTITY_NAME);
eo.setEditorRelationship(editor);
return eo;
}


public static NSArray<Review> fetchAllReviews(EOEditingContext editingContext) {
return _Review.fetchAllReviews(editingContext, null);
}


public static NSArray<Review> fetchAllReviews(EOEditingContext editingContext, NSArray<EOSortOrdering> sortOrderings) {
return _Review.fetchReviews(editingContext, null, sortOrderings);
}


public static NSArray<Review> fetchReviews(EOEditingContext editingContext, EOQualifier qualifier, NSArray<EOSortOrdering> sortOrderings) {
EOFetchSpecification fetchSpec = new EOFetchSpecification(_Review.ENTITY_NAME, qualifier, sortOrderings);
fetchSpec.setIsDeep(true);
NSArray<Review> eoObjects = (NSArray <Review>)editingContext.objectsWithFetchSpecification(fetchSpec);
return eoObjects;
}


public static Review fetchReview(EOEditingContext editingContext, String keyName, Object value) {
return _Review.fetchReview(editingContext, new EOKeyValueQualifier(keyName, EOQualifier.QualifierOperatorEqual, value));
}


public static Review fetchReview(EOEditingContext editingContext, EOQualifier qualifier) {
NSArray<Review> eoObjects = _Review.fetchReviews(editingContext, qualifier, null);
Review eoObject;
int count = eoObjects.count();
if (count == 0) {
eoObject = null;
}
else if (count == 1) {
eoObject = (Review)eoObjects.objectAtIndex(0);
}
else {
throw new IllegalStateException("There was more than one Review that matched the qualifier '" + qualifier + "'.");
}
return eoObject;
}


public static Review fetchRequiredReview(EOEditingContext editingContext, String keyName, Object value) {
return _Review.fetchRequiredReview(editingContext, new EOKeyValueQualifier(keyName, EOQualifier.QualifierOperatorEqual, value));
}


public static Review fetchRequiredReview(EOEditingContext editingContext, EOQualifier qualifier) {
Review eoObject = _Review.fetchReview(editingContext, qualifier);
if (eoObject == null) {
throw new NoSuchElementException("There was no Review that matched the qualifier '" + qualifier + "'.");
}
return eoObject;
}


public static Review localInstanceOfReview(EOEditingContext editingContext, Review eo) {
Review localInstance = (eo == null) ? null : (Review)EOUtilities.localInstanceOfObject(editingContext, eo);
if (localInstance == null && eo != null) {
throw new IllegalStateException("You attempted to localInstance " + eo + ", which has not yet committed.");
}
return localInstance;
}
}





===============================


ms

_______________________________________________
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

Regards,

Johan Henselmans
http://www.netsense.nl
Tel: +31-20-6267538
Fax: +31-20-6273852


 _______________________________________________
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

  • Follow-Ups:
    • Re: JavaEOGenerator running, but I do not understand the output.
      • From: Xavier Destombes <email@hidden>
    • Re: JavaEOGenerator running, but I do not understand the output.
      • From: Mike Schrag <email@hidden>
References: 
 >JavaEOGenerator running, but I do not understand the output. (From: Johan Henselmans <email@hidden>)
 >Re: JavaEOGenerator running, but I do not understand the output. (From: Mike Schrag <email@hidden>)
 >Re: JavaEOGenerator running, but I do not understand the output. (From: Johan Henselmans <email@hidden>)
 >Re: JavaEOGenerator running, but I do not understand the output. (From: Mike Schrag <email@hidden>)

  • Prev by Date: Re: Classpath State of the Union
  • Next by Date: Why has D2JC been deprecated?
  • Previous by thread: Re: JavaEOGenerator running, but I do not understand the output.
  • Next by thread: Re: JavaEOGenerator running, but I do not understand the output.
  • Index(es):
    • Date
    • Thread