Please use the google group to ask questions - thanks.

by Ilya Skorik 09 Jan 21:58
Best way to map field to Entity from another table?

Have two tables:

Table editions:

id integer,
name varchar,
type varchar,
date timestamp

DAO for editions:

@Entity
@Table(name="editions")
@ID Integer id;
String name
String type
Timestamp date


Table accounts:

id integer
edition integer

DAO for accounts:
@Entity
@Table(name="accounts")
@ID Integer id;
Ingeger edition;
String name;

I want automaticaly map "name" field from accounts DAO to table1.name column by FK accounts.edition = editions.id when I do Ebean.find(Accounts.class).findList();

09 Jan 22:46
by Ilya Skorik

I read this http://www.avaje.org/topic-4.html about Secondary Table, then I try write my Entity code like:

@Column(table="editions")
private String title;

But has received an error:

javax.persistence.PersistenceException: Query threw SQLException:ERROR: missing FROM-clause entry for table "a0"
??????????????: 122 Query was:
select a.id as c0, a.edition as c1, a.member as c2, a.enabled as c3, a.metadata as c4, a.created as c5, a.updated as c6, a0.title as c7
from accounts a
where a.enabled = ? and a.member = ?
order by a.title desc, a.created desc

Where I was mistaken?

11 Jan 00:32
by Rob

I think this is a bug but I'll have a look at this. Internally I need to update secondary columns to be supported in "partial object" queries.

I haven't done that work so I think you are hitting a bug here... but I'll have to look into it. I'm pretty sure the way to do this right now will be to use @Formula instead.

Cheers, Rob.

11 Jan 11:47
by Ilya Skorik

No, I did not inform on an error. I use your library of all some days, therefore is not strong understand it. I have thought that I have not considered something in a configuration.

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