On Oct 15, 2:21 am, Rob Bygrave <
robin.bygr...@gmail.com> wrote:
>*>> Indices on fields
>*
> Does this mean DDL generation of an DB Index for a field/property/column?
> Maybe you can give an example.
Yes in order to generate indices. For example:
public class Person
{
@ManyToOne(fetch = FetchType.LAZY)
@Index(name = "idx_person_address")
@JoinColumn(name = "incident")
private Address address;
....
}
>*>> Cache regions
>*
> Can you explain more about what you are missing/wanting here.
@Entity
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE, region =
"Company")
public class Person
@Entity
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE, region = "Global")
public class Country
Then in a config file we specify:
<cache
name="hibernate-.Company"
maxElementsInMemory="10000"
eternal="false"
timeToIdleSeconds="3600"
timeToLiveSeconds="3600"
overflowToDisk="false"
diskPersistent="false"
diskExpiryThreadIntervalSeconds="120"
/>
<cache
name="hibernate-.Global"
maxElementsInMemory="5000"
eternal="false"
timeToIdleSeconds="1800"
timeToLiveSeconds="1800"
overflowToDisk="false"
diskPersistent="false"
diskExpiryThreadIntervalSeconds="120"
/>
For example, we have an application to which several companies can
login, this data is company related. We also have information that is
used by all of them, we call this global info. We currently have this
divided into 2 cache regions. "company" and "global". I think you
could see this as dividing the bean cache into parts. I'm not sure if
you would benefit from using a config file as we mostly use the
default settings, but in the case of Hibernate you need to specify the
region names in the config. My personal flavor would be to scan for
regions in the class files but then again you'd have to guess for the
region size.
> Another approach that I have been thinking about is to provide a set of
> callback/visitor objects so that you (the developer) supply the sql/dml and
> use the PreparedStatement and ResultSet directly to set parameters and read
> the results ... but the management of the Connection and creating/closing of
> the PreparedStatement/ResultSet etc is handled for you.
Ah I missed that part :) I think getting the connection is good
enough. Your suggestion sounds nice. Maybe let the user provide a
callback class which implements an interface with a function that has
a connection argument. This would allow some space for Ebean to manage
the connection / transaction
>*>> missing the option to chain the order by statements
>*
I meant like the .where() and .having().
Ebean.find(Person.class).where().eq("name", "Pete");
Ebean.find(Person.class).order().asc("name");
Ebean.find(Person.class).group().asc("name");
Is there also a way to intercept all queries and saves? We have some
audit information we automatically update every time an entity is
saved or updated using an interceptor. This way we can log who edited
which entity etc. Also we add the company id to almost every query to
limit the load on the database and prevent companies from seeing each
others data.
Cheers for the quick feedback!