You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@cayenne.apache.org by atomix <sa...@yahoo.com> on 2012/02/09 10:21:00 UTC

How can I get the description of a table field, or field from CayenneObject

Hi all, I was quite new with Cayenne, how can I do this :

Book extends _Book

    public static final String DESCRIPTION_PROPERTY = "description";
    public static final String ID_BOOK_PROPERTY = "idBook";
    public static final String LEVEL_PROPERTY = "level";
    public static final String PATH_PROPERTY = "path";
    public static final String STATUS_PROPERTY = "status";
    public static final String TITLE_PROPERTY = "title";
....

How can I get the information of field (title, "title" , String ) which
inside CayenneObject , or I have to write the inspector by my own? ( There
some bean inspector library but I think Cayenne done that already, and other
hack will be ugly )...

-----------------------------
*Further :*

I'm intergrating Jasper with Cayenne and want to provide Jasper Designer
IReport a DataProvider , which in turn list the Field of the Table or Entity
to Roll through the Database ...

I was quite new with Cayenne so I can't find anywhere a way to get the field
description, name, title and so... from a CayenneObject like Book (which
generated by Cayenne Modeler ) , It's not too hard to type the names
manually but I still think there is a way to get this out by Cayenne.

Did anyone walk this line before, really appreciate the helping! 

--
View this message in context: http://cayenne.195.n3.nabble.com/How-can-I-get-the-description-of-a-table-field-or-field-from-CayenneObject-tp3728880p3728880.html
Sent from the Cayenne - User mailing list archive at Nabble.com.

Re: How can I get the description of a table field, or field from CayenneObject

Posted by Andrus Adamchik <an...@objectstyle.org>.
On Feb 9, 2012, at 12:30 PM, Aristedes Maniatis wrote:

>> Hi all, I was quite new with Cayenne, how can I do this :
>> 
>> Book extends _Book
>> 
>>     public static final String DESCRIPTION_PROPERTY = "description";
>>     public static final String ID_BOOK_PROPERTY = "idBook";
>>     public static final String LEVEL_PROPERTY = "level";
>>     public static final String PATH_PROPERTY = "path";
>>     public static final String STATUS_PROPERTY = "status";
>>     public static final String TITLE_PROPERTY = "title";
>> ....
>> 
>> How can I get the information of field (title, "title" , String ) which
>> inside CayenneObject , or I have to write the inspector by my own? ( There
>> some bean inspector library but I think Cayenne done that already, and other
>> hack will be ugly )...
> 
> There is a little ant task called cgen which creates the getters and setters for you.
> 
>  http://cayenne.apache.org/doc/ant-tasks.html

Also in runtime, you have access to ObjEntity object that contains all the entity ORM metadata. 

Book myBook = ... 
ObjEntity e = context.getEntityResolver().lookupObjEntity(myBook);

Andrus

Re: How can I get the description of a table field, or field from CayenneObject

Posted by Aristedes Maniatis <ar...@maniatis.org>.
On 9/02/12 8:50 PM, atomix wrote:
> Thank a lot Aristedes and Andrus
>
> You both point me very good directions which I don't know before. Cheer,
> this should really be written somewhere in the documentation!

You mean the page in the documentation which I linked you to?

  
> @Aristedes :
> Now assume we can use cgen Template to generate some other Class to suite
> our need (Japser intergration), are you and your team do that way or
> automaticly sync the two dataProvider and ObjEntity ,
>
> In our case we has a lot (~500 +) of Table , ObjEntity, and Report(s) for
> them, so each time we save XML, we want to generate all other things to make
> them perfectly match...
>
> Do you have any advice for the case, deeply appriciate that!

I don't understand. The ant task I pointed you at does exactly that.


Ari



-- 
-------------------------->
Aristedes Maniatis
GPG fingerprint CBFB 84B4 738D 4E87 5E5C  5EFA EF6A 7D2E 3E49 102A

Re: How can I get the description of a table field, or field from CayenneObject

Posted by atomix <sa...@yahoo.com>.
Thank a lot Aristedes and Andrus

You both point me very good directions which I don't know before. Cheer,
this should really be written somewhere in the documentation!

@Aristedes :
Now assume we can use cgen Template to generate some other Class to suite
our need (Japser intergration), are you and your team do that way or
automaticly sync the two dataProvider and ObjEntity ,

In our case we has a lot (~500 +) of Table , ObjEntity, and Report(s) for
them, so each time we save XML, we want to generate all other things to make
them perfectly match...

Do you have any advice for the case, deeply appriciate that! 

--
View this message in context: http://cayenne.195.n3.nabble.com/How-can-I-get-the-description-of-a-table-field-or-field-from-CayenneObject-tp3728880p3728953.html
Sent from the Cayenne - User mailing list archive at Nabble.com.

Re: How can I get the description of a table field, or field from CayenneObject

Posted by Aristedes Maniatis <ar...@maniatis.org>.
On 9/02/12 8:21 PM, atomix wrote:
> Hi all, I was quite new with Cayenne, how can I do this :
>
> Book extends _Book
>
>      public static final String DESCRIPTION_PROPERTY = "description";
>      public static final String ID_BOOK_PROPERTY = "idBook";
>      public static final String LEVEL_PROPERTY = "level";
>      public static final String PATH_PROPERTY = "path";
>      public static final String STATUS_PROPERTY = "status";
>      public static final String TITLE_PROPERTY = "title";
> ....
>
> How can I get the information of field (title, "title" , String ) which
> inside CayenneObject , or I have to write the inspector by my own? ( There
> some bean inspector library but I think Cayenne done that already, and other
> hack will be ugly )...

There is a little ant task called cgen which creates the getters and setters for you.

   http://cayenne.apache.org/doc/ant-tasks.html



>
> -----------------------------
> *Further :*
>
> I'm intergrating Jasper with Cayenne and want to provide Jasper Designer
> IReport a DataProvider , which in turn list the Field of the Table or Entity
> to Roll through the Database ...
>
> I was quite new with Cayenne so I can't find anywhere a way to get the field
> description, name, title and so... from a CayenneObject like Book (which
> generated by Cayenne Modeler ) , It's not too hard to type the names
> manually but I still think there is a way to get this out by Cayenne.
>
> Did anyone walk this line before, really appreciate the helping!


Yes. We use JasperReports and wrote our own data provider to do just that. It isn't too hard to glue it all together.


Ari



-- 
-------------------------->
Aristedes Maniatis
GPG fingerprint CBFB 84B4 738D 4E87 5E5C  5EFA EF6A 7D2E 3E49 102A