aspose file tools*
The moose likes Object Relational Mapping and the fly likes Hibernate simple Country mapping Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of JavaScript Promises Essentials this week in the JavaScript forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Hibernate simple Country mapping" Watch "Hibernate simple Country mapping" New topic
Forums: JSF Object Relational Mapping
Author

Hibernate simple Country mapping

Rene Forgues
Greenhorn

Joined: Dec 12, 2012
Posts: 1
Hi everyone,

I'm trying to do something really simple. Let be a table MusicBand, a table ShowEvent and a table Country (populated with all the countries in the world). The table are defined like this :

I have set up a little jsf page (with PrimeFaces) where I have a simple form allowing me to add ShowEvent for an alerady existing MusicBand. The ShowDate is selected from a PrimeFaces calendar component and the ShowCountry is selected from a PrimeFaces oneSelectMenu. The oneSelectMenu lists all the countries in the table Country (itemLabel = Country.CountryName and itemValue = Country.idCountry).

The ShowEvents added with this form are collected through a PrimeFaces collector component (see http://www.primefaces.org/showcase/ui/collector.jsf). This PrimeFaces object requires a List and an Object, respectively a variable List<ShowEvent> showEvents and a variable ShowEvent showEvent. I later have a Save button to save all the collected showEvents to the database (it saves the ShowEvent collection for an already specified MusicBand)

How should I map a relation like this with Hibernate if I wand to avoid something like :

Main goal is to be able to intialize the ShowCountry without loading a Country class. In fact, I would like to use the itemValue from the oneSelectMenu directly.


Thank you for reading!

Rene
Bill Gorder
Bartender

Joined: Mar 07, 2010
Posts: 1676
    
    7

Maybe I am misunderstanding something here. Since you are using session.load, you are not going to hit the database unless you try to access one of the accessors on the country object (other than id) and then only if you don't have the object in your cache, so I am unclear what you mean by 'without loading a Country class'

Anyway I will also add this the JSF forum. I am not a JSF expert but maybe someone there can provide you with a better way to do things.


[How To Ask Questions][Read before you PM me]
 
 
subject: Hibernate simple Country mapping