Please use the google group to ask questions - thanks.

by apoptosis 16 Mar 01:45
new ReflectionExpression

Yes it rhymes. :)

Construction would take a instance of an EntityBean, and a String like type (raw, startsWith, endsWith, contains).

For each mapped property in the EntityBean it would...

if (property != null) {
if (property !instanceof String || type == raw) {
add property value to where clause as eq
else
add string property to where clause with appropriate like
}

This will allow the equivalent to hibernate's:

session.createCriteria(Person.class).add(example).list();

AS

Ebean.createQuery(Person.class)
.where(new ReflectionExpression(example, "contains"));

16 Mar 11:11
by Rob

So this is like query by example... but with the option of specifying startsWith, endsWith, contains etc.

Is that right?

16 Mar 12:25
by apoptosis

Here is an example of how hibernate does it.

http://www.devx.com/Java/Article/28754/0/page/4

I wasn't trying to add options, hibernate has a MatchMode.X which tells it how to handle strings.

I started to code the ReflectionExpression myself, but got stuck trying to create a EntityBean from a Class. May I ask why your not using commons-beans?

16 Mar 23:03
by Rob

Thanks... thats a good link... and explains what you are after.

>> trying to create a EntityBean from a Class
Hmmm. I think you want to use/get the associated BeanDescriptor...

>> May I ask why your not using commons-beans?
Entity beans don't strictly have to be 'java beans' (although at the moment they commonly are for most people).

Aka, Ebean does not using reflection with field access/enhancement.

Create a New Topic

Title:
Body:
 
Introduction User Guide (pdf) Install/Configure Public JavaDoc Whitepapers
General Database Specific Byte Code Deployment Annotations Features
Top Bugs Top Enhancements
woResponse