Hi,
Problem:
I think how I should represent into "model tier"
data from "dictionary [read-only] table" from
"database tier".
Example of situation:
I have 2 tables:
1) t_accounts
2) t_roles
Inside 't_accounts' table I store data about persons
registered in my application. In "model tier" I represent
this data as CMP beans.
Inside 't_roles' table I store data about 'security roles'
used in my appliaction (every account can have many
roles). This table is "read-only" (or as you wish
"dictionary table" :)
Question:
How (better) I should represent data from 't_roles'
inside "model-tier"? As CMP, POJO bean, or better
manualy read contents of rows by JDBC?
Thanks && Greetings
Grzegorz Trafny
Grzegorz Trafny - 26 Aug 2004 12:37 GMT
> I think how I should represent into "model tier"
> data from "dictionary [read-only] table" from
> "database tier".
In Hibernate documentation (Reference, chapter 5.2.3)
I saw interesting construction which let to model persistent
(small) enum types. It's can be helpful during mapping
"dictionary tables" [from database tier] on objects [from
model tier]
It'a part of their example (without dd etc)
<code>
import net.sf.hibernate.PersistentEnum;
public class Color implements PersistentEnum {
private final int code;
private Color(int code) {
this.code = code;
}
public static final Color TABBY = new Color(0);
public static final Color GINGER = new Color(1);
public static final Color BLACK = new Color(2);
public int toInt() { ... }
public static Color fromInt(int code) { ... }
}
</code>
But how I can build such "persistence enurerator" in
CMP techmnology. To get code like:
<code>
public class Color implements EntityBean {
... ??? ...
}
</code>
Currently I use ordinary CMP bean without
'create' methods but this looks strange for me.
Any idea?
Greetings