Home Answers Viewqa Hibernate Joining Multiple table in Hibernate

 
 


Raul Estrela
Joining Multiple table in Hibernate
1 Answer(s)      a year and a month ago
Posted 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









Related Pages:
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
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
Data fetch from multiple SQL tables - Hibernate
keys. I have created hibernate mapping for each table, datasource...Data fetch from multiple SQL tables   I am in the process of writing my first hibernate application. I have a sql query that fetches data from
Criteria with Multiple Tables - Hibernate
Criteria with Multiple Tables  I am using Hibernates Criteria. How to get Joins using Criteria? e.g. instead of below query i want to use criteria...://www.roseindia.net/hibernate/ Hope that it will be helpful for you. Thanks
Hibernate Temporary Table
Hibernate Temporary Table   How can i create temporary table in Hibernate
Hibernate criteria count.
Hibernate criteria count.  How do we count rows using criteria in hibernate?   Create hibernate configuration file (hibernate.cfg.xml... create Persistent class ?Hibernate uses the Plain Old Java Object (POJO) classes
join multiple tables via hibernate criteria - Hibernate
join multiple tables via hibernate criteria  Dear all, i have a problem working with hibernate. i wanna join multiple tables via hibernate criteria. How can i do this operation? Thanks in advance regards Rosa
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
Joining two table using Natural Left join
Join Table with Natural left join In Natural Left join, both table are merge... to the first table's field values  means a left outer join returns all the values from the left table and matched values from the right table (NULL in case
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
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
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
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
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
creating table in hibernate
creating table in hibernate  how to create table by the help of hibernate   There are 2 alternatives to create table in hibernate: 1... javax.persistence.Table; @Entity @Table(name = "TBLCOURSES") public class Course
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
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
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
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
hibernate  How to know how many columns changed in a table when we are using hibernate
Using JOINING Operation in JDBC
Using JOINING Operation in JDBC   ... value must be unique within the table. We will use two related tables Student... from one table matches a foreign key in another table. Consider the SQL JOIN
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
Retrieve Value from Table - Hibernate
Retrieve Value from Table   Hai friend, I need help, How can i retrieve values From database using hibernate in web Application. As I new to hibernate I couldn't find solution for this problem.. Can anyone help please.. 
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
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
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
Create Dynamic Table using Hubernate
to use hibernate. Problem 3: How to upload multiple files to the servlet. I have...Create Dynamic Table using Hubernate  Thank's for reading my Post. I...: How to create seperate table for all users they sign up for my web app. i need
Natural Join / joining two tables
Natural Join / joining two tables  A join provide the facility to merge...; Here, "NATURAL JOIN"  join the two table according... tables before join -- "employee" table "emp_sal" table
send multiple textbox vaues in to an jsp form to store them in a DB table
send multiple textbox vaues in to an jsp form to store them in a DB table  Hi sir... I am not getting how can i send the multiple input text box... in to an database table. Please help me...... looking forward to hear from you
hibernate - Hibernate
hibernate    what is the lazy Loading in hibernate? can you give the example table ?  Lazy Loading in Hibernate In Hibernate, Lazy... in the program's operation. The syntax of lazy loading in Hibernate... public Entity
Joining two tables using Natural right join
Join Table with Natural Right join In Natural Right join, both table... to the Second table's field values  means a Right join returns all the values from the right table and matched values from the left table (NULL in case
Mysql Alter Add Multiple Columns
;    Mysql Alter Add Multiple Columns is used to modify the table and add multiple columns to the specified table. Understand with Example... sec) Query to alter Table named employees by adding multiple column
multiple fields in hashtable
multiple fields in hashtable  Hai,could anyone help me to implement the object car fields speed,make & color in Hash table
Hibernate - Hibernate
Hibernate   Dear sir Thanks for your previous answers its really... ,hibernate, jboss, oracle) one is 1) Express and 2) MDM(All master data... 192.168.1.2 using hibernate(Schema name Express) In MDM i am connecting
Hibernate Count Query
Hibernate Count Query       In this section we will show you, how to use the Count Query. Hibernate supports multiple aggregate functions. when they are used in HQL queries
Hibernate - Hibernate
Hibernate SessionFactory  Can anyone please give me an example of Hibernate SessionFactory?  Hi friend,package roseindia;import...;1.0"?><!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate
Use of delete() method in hibernate.
Use of delete() method in hibernate.  Define the use of delete() method of hibernate?   Hibernate provide the facility to delete one row or multiple row from a table. Here is an example. Example: package
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
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
Hibernate - Hibernate
Hibernate pojo example  I need a simple Hibernate Pojo example ...){ System.out.println(e.getMessage()); } finally{ } }}hibernate mapping <class name="roseindia.HibernatePojoExample" table="pojoinformation">
Hibernate Avg() Function (Aggregate Functions)
to use the avg() function. Hibernate supports multiple aggregate functions. When... Hibernate Avg() Function (Aggregate Functions)  ...() function aggregates the average value of the given column.  Table Name
Hibernate Max() Function (Aggregate Functions)
to use the Max() function. Hibernate supports multiple aggregate functions. When... Hibernate Max() Function (Aggregate Functions...() function aggregates the maximum value of the given column.  Table Name
Hibernate Min() Function (Aggregate Functions)
the Min() function. Hibernate supports multiple aggregate functions. When... Hibernate Min() Function (Aggregate Functions)  ... aggregates the minimum value of the given column.  Table Name: insurance ID
hibernate - Hibernate
hibernate  hi i am new to hibernate. i wan to run a select query... hibernate for use SessionFactory sessionFactory = new Configuration...://www.roseindia.net * Java Class to map to the database insurance table */ public
Hibernate - Hibernate
Hibernate  Hai this is jagadhish while running a Hibernate... PM org.hibernate.tool.hbm2ddl.TableMetadata INFO: table found: SCOTT.EMPLOYEE.../hibernate/ Please specify your requirements in detail. It would be good
Mysql Alter Multiple Columns
Mysql Alter Multiple Columns       Mysql Alter Multiple Columns is used to modify the table definition and rename the columns name in a table. Understand with Example The Tutorial
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
Hibernate code - Hibernate
Hibernate code   how to write hql query for retriveing data from multiple tables
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

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.