Hibernate: Load entities with Formula

2020-03-30 06:28发布

问题:

Is it possible to load an entity using a Formula?

For example:

@formula("(select * from myEntity ent where ent.isLatest = TRUE )")
publicmyEntity getmyEntity()
{
    return this.associatedPatientJournalEntries;
}

if so, how does the mapping have to look.

Also, what are alternatives to using formulas to load certain entities?

回答1:

You can, but the formula looks:

select ent from myEntity ent where ent.isLatest

Another alternatives are,

mounting the entity in your method.

post loading method