Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / JavaBeans / August 2004

Tip: Looking for answers? Try searching our database.

pattern for representing read-only data in app-tier

Thread view: 
Grzegorz Trafny - 25 Aug 2004 12:39 GMT
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


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.