listbox and hibernate

asked 2012-02-15 20:33:10 +0800

grzesiek gravatar image grzesiek flag of Poland
72 1 5

i got an issue with data and listbox, I’m trying put data from three joined tables to listbox and it doesn’t work, the problem is probably in hibernate but I can’t resolve it.


actor(actor_id, first_name, last_name)
film_actor (actor_id, film_id)
film(film_id, title)

these tables are correctly maped because it works fine with each table separate but I want to get list() like this: list<ActorFilm> where ActorFilm is class defined below:

public class ActorFilm implements java.io.Serializable {
private String firstName;
private String lastName;
private String title;
public ActorFilm () {
public ActorFilm (String firstName, String lastName, String title) {
this.firstName = firstName;
this.lastName = lastName;
this.title = title;

I’ve tried use code:
String sql= "SELECT actor.first_name, actor.last_name, film.title FROM (sakila.film_actor film_actor JOIN sakila.film film ON (film_actor.film_id = film.film_id)) JOIN sakila.actor actor ON (film_actor.actor_id = actor.actor_id) WHERE (actor.first_name = 'PENELOPE')";

List< ActorFilm > actfilms=currentSession.createSQLQuery(sql).list();

And it doesn’t work

delete flag offensive retag edit

2 Replies

Sort by » oldest newest

answered 2012-02-15 20:46:08 +0800

satan87 gravatar image satan87



List< ActorFilm > actfilms = currentSession.createQuery(" Select a from ActorFilm a where a.actor_id=" + [id of the actor]).list();

link publish delete flag offensive edit

answered 2012-02-16 21:38:44 +0800

grzesiek gravatar image grzesiek flag of Poland
72 1 5

it's not working because in database doesn't exist table corresponds to the class ActorFilm in other words I want to present data from related tables (actor, film) in one listbox

please help

link publish delete flag offensive edit
Your reply
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools




Asked: 2012-02-15 20:33:10 +0800

Seen: 180 times

Last updated: Feb 16 '12

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More