using GenericDelegator: what is the MAX() functional equivalent?

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

using GenericDelegator: what is the MAX() functional equivalent?

natx
Hey everybody. I hope this is an appropriate question for this particular branch of the forum.

Basically, I have a few Ofbiz entities set up which point to tables in a MySQL database. These tables all have a numeric field called "id" which acts as the primary key (established using the <prim-key field="id"/construct). I'd like to have these id fields populated with a numeric sequence generator which insures uniqueness.

I'm pretty new to Ofbiz, so the first thing I did was look for a way to do this manually by using the equivalent to the MAX function in SQL to find the next number in the sequence. However, I wasn't able to find any use of the MAX function, unless I wanted to create a View Entity (which seems unnecessary). So my first question is: is there any equivalent to the MAX function when using the GenericDelegator to run database queries?

Note: I just discovered the existence of the getNextSeqId() method in GenericDelegator. Since there is an entity called "SequenceValueItem" in our entity model, I'm assuming that this will serve my purpose. But my first question still stands. Thanks!

-- Nate
Reply | Threaded
Open this post in threaded view
|

Re: using GenericDelegator: what is the MAX() functional equivalent?

David E Jones

Nate,

Check out the view-entity and DynamicViewEntity stuff in the Entity  
Engine (the Entity Engine Guide has some details on these). These  
support sets of fields with group by and functions for aggregated data.

-David


On Feb 15, 2007, at 8:21 AM, natx wrote:

>
> Hey everybody. I hope this is an appropriate question for this  
> particular
> branch of the forum.
>
> Basically, I have a few Ofbiz entities set up which point to tables  
> in a
> MySQL database. These tables all have a numeric field called "id"  
> which acts
> as the primary key (established using the <prim-key field="id"/
> construct).
> I'd like to have these id fields populated with a numeric sequence  
> generator
> which insures uniqueness.
>
> I'm pretty new to Ofbiz, so the first thing I did was look for a  
> way to do
> this manually by using the equivalent to the MAX function in SQL to  
> find the
> next number in the sequence. However, I wasn't able to find any use  
> of the
> MAX function, unless I wanted to create a View Entity (which seems
> unnecessary). So my first question is: is there any equivalent to  
> the MAX
> function when using the GenericDelegator to run database queries?
>
> Note: I just discovered the existence of the getNextSeqId() method in
> GenericDelegator. Since there is an entity called  
> "SequenceValueItem" in our
> entity model, I'm assuming that this will serve my purpose. But my  
> first
> question still stands. Thanks!
>
> -- Nate
> --
> View this message in context: http://www.nabble.com/using- 
> GenericDelegator%3A-what-is-the-MAX%28%29-functional-equivalent--
> tf3234318.html#a8987232
> Sent from the OFBiz - User mailing list archive at Nabble.com.
>


smime.p7s (3K) Download Attachment