Joining Multiple table in Hibernate

Joining Multiple table in Hibernate

Hi everyone,

I'm new to Hibernate (even in JAVA), and I'm having some doubt's about one thing. I created 2 tables in PostgreSQL with 1 to many relationship, and now i'm trying to test some queries to them. Tables names are TbPessoa (one) and TbTelefone(many).

TbPessoa - idPessoa(pk), usNome(charvar), usIdade(int), usTelefone(int)

TbTelefone - idTelefone(pk), usIOperadora(charvar), usTarifario(charvar), usData(date), idPessoa(int)

Foreign Key on TbTelefone referencing TbPessoa (idPessoa to idPessoa on TbPessoa).

I'm trying to create a query where I would get the items where usNome='Peter' OR usOperadora='Vodafone' like we can do with SQL statments like,

SELECT usNome, usOperadora
FROM TbPessoa, TbTelefone
WHERE usNome='Peter' OR usOperadora='Vodafone'***

Finnaly, I need to know how a can print (using System.out.println) the query results. I've been using (just for one table) this:

transaction = session.beginTransaction();
@SuppressWarnings("unchecked")
String query = "SELECT FROM TbPessoa";

List <TbPessoa> lista = session.createQuery(query).list();

int i=0;

for( TbPessoa x : lista ) {

System.out.println( "Id: " + x.getIdPessoa() + "| Nome: " + x.getUsNome() + "| Idade:" + x.getUsIdade() + "| Morada: " + x.getUsMorada() + "| Nr. Telefone: " + x.getUsTelefone());

}

Sorry my bad English! Thanks!

Kind Regards, Raul

View Answers

Ads









Related Tutorials/Questions & Answers:
Joining Multiple table in Hibernate
Joining Multiple table in Hibernate  Hi everyone, I'm new to Hibernate (even in JAVA), and I'm having some doubt's about one thing. I created 2... (using System.out.println) the query results. I've been using (just for one table
Hibernate joining multiple tables
Hibernate joining multiple tables  In join sample program, what do we mean by the line? String sql_query = "from Product p inner join p.dealer as d... group by p.name"; For more information, visit the following link: Hibernate
Advertisements
Hibernate Temporary Table
Hibernate Temporary Table   How can i create temporary table in Hibernate
Hibernate envers revinfo table
Hibernate envers revinfo table  Hi, What is the structure of hibernate envers revinfo table? What is the use of envers revinfo table and its structure? Thanks
mysql alter table add multiple columns
mysql alter table add multiple columns  Hi, I have a table in database. I want to add multiple columns into existing table. What is the code for mysql alter table add multiple columns? Thanks   Hi, You can use
How to update table in Hibernate
How to update table in Hibernate  Hi, I have a table in database that has two fields in it. Student Name and ID, can anyone explain me how to update these tables in Hibernate. Thanks.   Update table query in Hibernate
SQL Alter Table Add Multiple Columns
SQL Alter Table Add Multiple Columns       Alter Table Add Multiple Columns in SQL... Add Multiple Columns. The SQL Query create a table 'Stu_Table' with table
Hibernate Criteria Multiple or
Hibernate Criteria Multiple or You can implements multiple or in hibernate... of multiple or is given below CriteriaMultipleOr.java package... run this application it will display message as shown below: Hibernate
Retrieve multiple data from database into Table.....
Retrieve multiple data from database into Table.....   hi........... I want to Retrieve multiple data from database into Table but i am not able to.... i am only able to retrieve one value not more than that. means in my
delete row from a table in hibernate
delete row from a table in hibernate  is there method to delete row in a table using hibernate like save(-) to insert row
is it possible to connect the multiple databases from the hibernate application
is it possible to connect the multiple databases from the hibernate application  is it possible to connect the multiple databases from the hibernate application,if it is possible then tell me with step wise manner
SQL Alter Table Add Multiple Columns
SQL Alter Table Add Multiple Columns       Alter Table Add Multiple Columns in SQL... Add Multiple Columns. The SQL Query create a table 'Stu_Table
Hibernate table not mapped error - solution
Hibernate table not mapped error - solution  Hi, What is the reason of Hibernate table not mapped error and it can be solved? Thanks   HI... configuration of Entity class in Hibernate. Hibernate is ORM framework in Java which
Retrieving value from multiple table in database
Retrieving value from multiple table in database  Hi fnds, I want to maintain the financial database of 20 users for 1 year and update the details... created 12 tables with table name - month1,month2,....,upto month12.. each table
can we update table in hibernate with out primary key in table?
can we update table in hibernate with out primary key in table?  can we update table in hibernate with out primary key in table
Hibernate Envers custom revinfo table
Hibernate Envers custom revinfo table  Hi, How to use the custom table instead of revinfo table? I don't want to use the default table I want to give another name for this table. How to do this? Thanks
Hibernate Envers - REVINFO table doesn't exist
Hibernate Envers - REVINFO table doesn't exist  Hi, In my project I...: Hibernate Envers - REVINFO table doesn't exist How to resolve this? Thanks... hibernate to create table automatically. For this add following property
Joining tables using criteria
Joining tables using criteria  How do i join more than three tables and retrieve one column from parent table and count of unique values in a single column from child table,the joined tables must be maintain primary key
Hibernate envers custom revinfo table
Hibernate envers custom revinfo table - How to specify custom  revinfo table? In this tutorial we are going to teach you to configure the Hibernate... in the tutorial. In Hibernate envers its possible to use the custom revinfo table
How properties of a class are mapped to the columns of a database table in Hibernate?
of a database table in Hibernate? Hibernate 5 is very powerful yet flexible ORM... properties to database table Hibernate 5 is mostly using the annotations... to many relationship mapping @JoinTable - Joining entity @JoinColumn - Table
How properties of a class are mapped to the columns of a database table in Hibernate?
of a database table in Hibernate? Hibernate 5 is very powerful yet flexible ORM... properties to database table Hibernate 5 is mostly using the annotations... to many relationship mapping @JoinTable - Joining entity @JoinColumn - Table
How properties of a class are mapped to the columns of a database table in Hibernate?
of a database table in Hibernate? Hibernate 5 is very powerful yet flexible ORM... properties to database table Hibernate 5 is mostly using the annotations... to many relationship mapping @JoinTable - Joining entity @JoinColumn - Table
How properties of a class are mapped to the columns of a database table in Hibernate?
of a database table in Hibernate? Hibernate 5 is very powerful yet flexible ORM... properties to database table Hibernate 5 is mostly using the annotations... to many relationship mapping @JoinTable - Joining entity @JoinColumn - Table
Delete database Table through hibernate and Spring
Delete database Table through hibernate and Spring  Hi, I am using Spring,Hibernate and Tapestry to save and also fetch data simultaneously from... once without repetation,or Detete table after data is fetched. Here
Mysql Multiple Date Insert
multiple data to the table. Understand with Example The Section of Tutorial... sec) Query for Multiple insertion of data in table: The Query insert into is used for Multiple insertion of data in table 'Employee'. The Query
Mysql Multiple Date Insert
multiple data to the table. Understand with Example The Section of Tutorial... (0.01 sec) Query for Multiple insertion of data in table: The Query insert into is used for Multiple insertion of data in table 'Employee
delete row from a table using hibernate
delete row from a table using hibernate  //code in java file String hql="delete from CONTACT c where ID=6"; Query query=session.createQuery(hql); //error when executing above code CONTACT is not mapped
Mysql Alter Add Multiple Columns
the table and add multiple columns to the specified table. Understand with Example...) Query to alter Table named employees by adding multiple column named city: The Query below given is used to modify the table 'employees' and add multiple
Hibernate Criteria load all objects from table
Hibernate Criteria load all objects from table - Learn how to load all... from a table then you can easily use the Hibernate Criteria load all objects... the Hibernate Criteria Query to fetch all data from a table. Read more
ModuleNotFoundError: No module named 'django-joining'
ModuleNotFoundError: No module named 'django-joining'  Hi, My... named 'django-joining' How to remove the ModuleNotFoundError: No module named 'django-joining' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'django-joining'
ModuleNotFoundError: No module named 'django-joining'  Hi, My... named 'django-joining' How to remove the ModuleNotFoundError: No module named 'django-joining' error? Thanks   Hi, In your python
how to get multiple hyperlink values from a table column to another jsp file?
how to get multiple hyperlink values from a table column to another jsp file... for the user string in the database, as a result a table will come up with 3 columns itemid...="history.go(-1);return true;"/> <table border="1" style="table-layout
Hibernate Insert
This tutorial will help you to learn how to insert data into table by using hibernate
hibernate
hibernate  when we using schemaExport in hibernate every time it drops the existing table and create new table ,if table contain dependent table then is it drop
Mysql Alter Multiple Columns
Mysql Alter Multiple Columns       Mysql Alter Multiple Columns is used to modify the table... multiple column's of  Table named employee1: The Query alter modifies
table
table  multiplicatyion table
i want to create an application with only a button which on click displays table from database using struts2 and hibernate on eclipse
i want to create an application with only a button which on click displays table from database using struts2 and hibernate on eclipse  please help me i have to submit this soon
Table
Table  How i generate table in showMessageDialog. I want that i creat a table and run in showMessageDialogeprint("cprint("code sample");ode sample
Hibernate One to One Mapping using XML
In this section, you will learn One to One mapping of table in Hibernate using Xml
Table
Table  How I generate table in showMessageDialog. E.g 3X1=3 3X2=6 3X3=9print("code sample
Table
Table  How i generate table in showMessageDialog. I want to creat a table and run in showMessageDialoge. Pl make a table programe which run..., JOptionpane, Integer.parseInt. Please use only these above methods to make table
hibernate
hibernate  How to know how many columns changed in a table when we are using hibernate
table
input from oracle table(my database table..) This is a very important table of my
table
table  Hi..I have a list of links which links to a table in the same page.If I click first link the table is displayed at the top, likewise if i click the last link the table is displayed at the last,i dont know how to set
Table
Table  How i generate table in JOptionpane.showMessageDialog... advance coding but i want u make the table using JOptionpane.showMessageDialog, import.javax.swing int Integer.parseInt(). Thats my limit. Pl generata a table
table?
table?  Hi, how could i make a table in javascript, which would look like this: AA CODON Number /1000 Fraction .. (this row... can't figure out, how to construct a table,with two fixed columns, one that reads
Table
Table  Why u dont understand sir?? I want to make a table program which generate a table on showMessageDialog. I have learnt these methods until now... methods to be used. Write a table program which use only and only these above methods
Table
Table  How i create table on showMessageDialog using JOptionpane and Integer.parseInt. No other method to use. Pl make a program which generate 5X1=5 5X2=10 5X3=15   Hi Friend, Try this: import javax.swing.*; import
Hibernate
Hibernate  Hi i have 2 doubbts regarding Hibernate ,.. 1)Can we rename hibernate.cfg.xml? 2? can we use multiple mapping resource in hibernate.cf.xml file ? pls let me know soon
delete multiple row using checkbox
delete multiple row using checkbox  how to delete multiple row in a table which is connected to database using checkbox

Ads