You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@cayenne.apache.org by Joe Baldwin <jf...@earthlink.net> on 2015/07/31 18:50:04 UTC

A bunch of stuff is deprecated.

I hope you enjoyed my technical description in the subject heading. :)  But it is, in fact, accurate.

(Context: I am converting from 3.0 to 4.0):

I have been following Cayenne best practices and have been building queries (and quite a few of the, I might add) with Cayenne-Entity-Property conventions.  Simple example:

	Expression exp = ExpressionFactory.matchExp(Product.IS_DISABLED_PROPERTY, false);

In addition, I have been using the Cayenne PROPERTY definitions as part of my core logic.

Now I find (in 4.0) that all of these PROPERTY definitions are Deprecated.

Other than my personal opinion, that I am not terribly excited about the prospect of ripping out all of my core logic,  I would like to find out if this conversion is going to be easier that I estimate.   (As usual, I have tried to search the docs and could not find a good “how-to” for a simple functional replacement that would also give me access to the String value of the property (for display purposes).

Question:
If there is a good how-to/tutorial, please provide the link, if not, then could you please provide one simple example and one more complex example so I can get to work on this?

Thanks
Joe


Re: A bunch of stuff is deprecated.

Posted by Andrus Adamchik <an...@objectstyle.org>.
In 4.0 M3, we un-deprecated props in the template, as it was annoying indeed. Instead we made their generation optional per https://issues.apache.org/jira/browse/CAY-1991 . So if you have a new app, you won't get String properties, only Property objects. If you want to try it, you can get an unofficial build of Cayenne HEAD from here:

http://maven.objectstyle.org/nexus/content/repositories/cayenne-unofficial/org/apache/cayenne/cayenne-server/4.0.M3.0ac54cb/

In M2 your option is to use a custom cgen template, removing deprecation stuff. 

Andrus

> On Jul 31, 2015, at 8:08 PM, Mike Kienenberger <mk...@gmail.com> wrote:
> 
> I haven't gotten to the point of converting from 3.x to 4.x, but I'm
> surprised to hear that the entity *_PROPERTY fields are deprecated.
> These values are generated in the templates, so they're totally under
> the developer's control.  They're not considered part of the cayenne
> core library since you can customize your generated _superclass file
> or even do away with it completely.
> 
> When I look at ....git/cayenne/cayenne-tools/src/main/resources/templates/v1_2/superclass.vm,
> I don't see any indication that the generated properties are
> deprecated.
> 
> Maybe I am misunderstanding what you are asking about?
> 
> 
> On Fri, Jul 31, 2015 at 12:50 PM, Joe Baldwin <jf...@earthlink.net> wrote:
>> I hope you enjoyed my technical description in the subject heading. :)  But it is, in fact, accurate.
>> 
>> (Context: I am converting from 3.0 to 4.0):
>> 
>> I have been following Cayenne best practices and have been building queries (and quite a few of the, I might add) with Cayenne-Entity-Property conventions.  Simple example:
>> 
>>        Expression exp = ExpressionFactory.matchExp(Product.IS_DISABLED_PROPERTY, false);
>> 
>> In addition, I have been using the Cayenne PROPERTY definitions as part of my core logic.
>> 
>> Now I find (in 4.0) that all of these PROPERTY definitions are Deprecated.
>> 
>> Other than my personal opinion, that I am not terribly excited about the prospect of ripping out all of my core logic,  I would like to find out if this conversion is going to be easier that I estimate.   (As usual, I have tried to search the docs and could not find a good “how-to” for a simple functional replacement that would also give me access to the String value of the property (for display purposes).
>> 
>> Question:
>> If there is a good how-to/tutorial, please provide the link, if not, then could you please provide one simple example and one more complex example so I can get to work on this?
>> 
>> Thanks
>> Joe
>> 
> 


Re: A bunch of stuff is deprecated.

Posted by Mike Kienenberger <mk...@gmail.com>.
I haven't gotten to the point of converting from 3.x to 4.x, but I'm
surprised to hear that the entity *_PROPERTY fields are deprecated.
These values are generated in the templates, so they're totally under
the developer's control.  They're not considered part of the cayenne
core library since you can customize your generated _superclass file
or even do away with it completely.

When I look at ....git/cayenne/cayenne-tools/src/main/resources/templates/v1_2/superclass.vm,
I don't see any indication that the generated properties are
deprecated.

Maybe I am misunderstanding what you are asking about?


On Fri, Jul 31, 2015 at 12:50 PM, Joe Baldwin <jf...@earthlink.net> wrote:
> I hope you enjoyed my technical description in the subject heading. :)  But it is, in fact, accurate.
>
> (Context: I am converting from 3.0 to 4.0):
>
> I have been following Cayenne best practices and have been building queries (and quite a few of the, I might add) with Cayenne-Entity-Property conventions.  Simple example:
>
>         Expression exp = ExpressionFactory.matchExp(Product.IS_DISABLED_PROPERTY, false);
>
> In addition, I have been using the Cayenne PROPERTY definitions as part of my core logic.
>
> Now I find (in 4.0) that all of these PROPERTY definitions are Deprecated.
>
> Other than my personal opinion, that I am not terribly excited about the prospect of ripping out all of my core logic,  I would like to find out if this conversion is going to be easier that I estimate.   (As usual, I have tried to search the docs and could not find a good “how-to” for a simple functional replacement that would also give me access to the String value of the property (for display purposes).
>
> Question:
> If there is a good how-to/tutorial, please provide the link, if not, then could you please provide one simple example and one more complex example so I can get to work on this?
>
> Thanks
> Joe
>

Re: A bunch of stuff is deprecated.

Posted by Joe Baldwin <jf...@earthlink.net>.
Andrus,

OK. Please let me verify my understanding. So for example, if I had created an expression like:

	Expression exp = ExpressionFactory.matchExp(Product.IS_DISABLED_PROPERTY, false);
	exp = exp.andExp(ExpressionFactory.matchExp(Product.IS_VINTAGE_PROPERTY, false));

the new equivalent would be

	Expression exp = Product.IS_DISABLED.isFalse();
	exp = exp.andExp(Product.IS_VINTAGE.isFalse());

producing the SQL

	System.out.println("expression: " + exp);


and an Attribute name/value for “vintage” would be printed as

	System.out.println("isVintage: " + Product.IS_VINTAGE.getName());

This looks pretty concise and easy to replace to me.

Question:
Is that the new “best practice”?   Are there any other new (expression/ordering) tricks I should look into?

Thanks
Joe



> On Jul 31, 2015, at 1:25 PM, Andrus Adamchik <an...@objectstyle.org> wrote:
> 
> 
>> On Jul 31, 2015, at 7:50 PM, Joe Baldwin <jf...@earthlink.net> wrote:
>> 
>> functional replacement that would also give me access to the String value of the property (for display purposes).
> 
> Here is an example:
> 
> (generated code)
> 
>  @Deprecated
>  public static final String TITLE_PROPERTY = "title";
>  public static final Property<String> TITLE = new Property<String>("title");
> 
> (accessing property name in a new way)
> 
>  TITLE.getName();
> 
> But the point of the new API is to replace code like this:
> 
>  Expression exp = ExpressionFactory.matchExp(Product.IS_DISABLED_PROPERTY, false);
> 
> with this:
> 
>  Expression exp = Product.IS_DISABLED.isFalse();
> 
> Which does not require knowing the property name. IIRC 4.0 tutorial has other examples of expressions using the new API.
> 
> Andrus
> 


Re: A bunch of stuff is deprecated.

Posted by Andrus Adamchik <an...@objectstyle.org>.
Yeah, that's the new way of doing things. Also check out with ObjectSelect, SelectById and SQLSelect query classes:

https://cayenne.apache.org/docs/4.0/upgrade-guide/ar01.html#framework-api



> On Jul 31, 2015, at 9:43 PM, Joe Baldwin <jf...@earthlink.net> wrote:
> 
> Oops, I missed this one.
> 
> So
> 
> 	order = new Ordering(Product.NAME_PROPERTY, SortOrder.ASCENDING);
> 
> would now be something like:
> 
> 	order = Product.NAME.ascInsensitive();
> 
> I think I get it now - that is pretty slick! :)
> 
> Joe
> 
> 
> 
>> On Jul 31, 2015, at 1:25 PM, Andrus Adamchik <an...@objectstyle.org> wrote:
>> 
>> 
>>> On Jul 31, 2015, at 7:50 PM, Joe Baldwin <jf...@earthlink.net> wrote:
>>> 
>>> functional replacement that would also give me access to the String value of the property (for display purposes).
>> 
>> Here is an example:
>> 
>> (generated code)
>> 
>> @Deprecated
>> public static final String TITLE_PROPERTY = "title";
>> public static final Property<String> TITLE = new Property<String>("title");
>> 
>> (accessing property name in a new way)
>> 
>> TITLE.getName();
>> 
>> But the point of the new API is to replace code like this:
>> 
>> Expression exp = ExpressionFactory.matchExp(Product.IS_DISABLED_PROPERTY, false);
>> 
>> with this:
>> 
>> Expression exp = Product.IS_DISABLED.isFalse();
>> 
>> Which does not require knowing the property name. IIRC 4.0 tutorial has other examples of expressions using the new API.
>> 
>> Andrus
>> 
> 
> 


Re: A bunch of stuff is deprecated.

Posted by Joe Baldwin <jf...@earthlink.net>.
Oops, I missed this one.

So

	order = new Ordering(Product.NAME_PROPERTY, SortOrder.ASCENDING);

would now be something like:

	order = Product.NAME.ascInsensitive();

I think I get it now - that is pretty slick! :)

Joe



> On Jul 31, 2015, at 1:25 PM, Andrus Adamchik <an...@objectstyle.org> wrote:
> 
> 
>> On Jul 31, 2015, at 7:50 PM, Joe Baldwin <jf...@earthlink.net> wrote:
>> 
>> functional replacement that would also give me access to the String value of the property (for display purposes).
> 
> Here is an example:
> 
> (generated code)
> 
>  @Deprecated
>  public static final String TITLE_PROPERTY = "title";
>  public static final Property<String> TITLE = new Property<String>("title");
> 
> (accessing property name in a new way)
> 
>  TITLE.getName();
> 
> But the point of the new API is to replace code like this:
> 
>  Expression exp = ExpressionFactory.matchExp(Product.IS_DISABLED_PROPERTY, false);
> 
> with this:
> 
>  Expression exp = Product.IS_DISABLED.isFalse();
> 
> Which does not require knowing the property name. IIRC 4.0 tutorial has other examples of expressions using the new API.
> 
> Andrus
> 


Re: A bunch of stuff is deprecated.

Posted by Andrus Adamchik <an...@objectstyle.org>.
> On Jul 31, 2015, at 7:50 PM, Joe Baldwin <jf...@earthlink.net> wrote:
> 
> functional replacement that would also give me access to the String value of the property (for display purposes).

Here is an example:

(generated code)

  @Deprecated
  public static final String TITLE_PROPERTY = "title";
  public static final Property<String> TITLE = new Property<String>("title");

(accessing property name in a new way)

  TITLE.getName();

But the point of the new API is to replace code like this:

  Expression exp = ExpressionFactory.matchExp(Product.IS_DISABLED_PROPERTY, false);

with this:

  Expression exp = Product.IS_DISABLED.isFalse();

Which does not require knowing the property name. IIRC 4.0 tutorial has other examples of expressions using the new API.

Andrus