get all fields of an Entity

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

get all fields of an Entity

Gabriel Oberreuter
Hi all,

Do anyone knows how to get all fields of a given Entity programmatically? I can't seem to find that functionality of just lack the java knowledge to just do it.

I am creating a query and want to select "all" current fields of an entity. When executing the query, I can pass a Set of fields to select. I need something of the like:

Set<String> fieldsOfEntityInvoice = Invoice.getAllEntityFields();

For now, I am building the Set manually, adding each field of the entities using set.add("invoiceId"), for example.

Thanks
Reply | Threaded
Open this post in threaded view
|

Re: get all fields of an Entity

Jeremy Olmstead
If you pass null as your set of fields, it will select all fields.

Jeremy

On Wed, Jan 20, 2016 at 9:47 AM, Gabriel Oberreuter <[hidden email]>
wrote:

> Hi all,
>
> Do anyone knows how to get all fields of a given Entity programmatically? I
> can't seem to find that functionality of just lack the java knowledge to
> just do it.
>
> I am creating a query and want to select "all" current fields of an entity.
> When executing the query, I can pass a Set of fields to select. I need
> something of the like:
>
> Set<String> fieldsOfEntityInvoice = Invoice.getAllEntityFields();
>
> For now, I am building the Set manually, adding each field of the entities
> using set.add("invoiceId"), for example.
>
> Thanks
>
>
>
> --
> View this message in context:
> http://ofbiz.135035.n4.nabble.com/get-all-fields-of-an-Entity-tp4676259.html
> Sent from the OFBiz - User mailing list archive at Nabble.com.
>
Reply | Threaded
Open this post in threaded view
|

Re: get all fields of an Entity

Gabriel Oberreuter
Jeremy Olmstead wrote
If you pass null as your set of fields, it will select all fields.

Jeremy
Oh, thanks. That works great to select all fields when executing the query.

I still need to get all fields of an entity at other parts of our code, do you know how to achieve this?
Reply | Threaded
Open this post in threaded view
|

Re: get all fields of an Entity

Jeremy Olmstead
Something like this should work:

        ModelEntity modelEntity = delegator.getModelEntity("Invoice");
        List<String> fieldNames = modelEntity.getAllFieldNames();


On Wed, Jan 20, 2016 at 10:37 AM, Gabriel Oberreuter <[hidden email]>
wrote:

> Jeremy Olmstead wrote
> > If you pass null as your set of fields, it will select all fields.
> >
> > Jeremy
>
> Oh, thanks. That works great to select all fields when executing the query.
>
> I still need to get all fields of an entity at other parts of our code, do
> you know how to achieve this?
>
>
>
>
> --
> View this message in context:
> http://ofbiz.135035.n4.nabble.com/get-all-fields-of-an-Entity-tp4676259p4676262.html
> Sent from the OFBiz - User mailing list archive at Nabble.com.
>