Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa EJB Join problem with JPA Criteria Builder
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


David Palomo
Join problem with JPA Criteria Builder
0 Answer(s)      3 years and 3 months ago
Posted in : EJB


I need to make this Query in criteria Builder. At this momento I?´m making it like this:

Root<Setting> settingRoot = cr.from(Setting.class);
    Join<Setting, SettingValue> settingValueRoot = settingRoot.join("SettingValues", JoinType.LEFT);


    if (filter.settingLevel == SettingData.SETTING_LEVEL_USER) {
        Join<SettingValue, User> userRoot = settingValueRoot.join("User", JoinType.LEFT);
        setCriteriaQuery(cb, cr, filter, settingRoot, settingValueRoot, userRoot);  

And the query I get is the next one:

select setting0_.code as col_0_0_, setting0_.setting_name as col_1_0_, setting0_.setting_level as col_2_0_, settingsgr3_.setting_group_name as col_3_0_, setting0_.setting_order as col_4_0_, settingval1_.setting_value as col_5_0_, user2_.name as col_6_0_, user2_.id as col_7_0_, settingsgr3_.group_order as col_8_0_, setting0_.settings_group_id as col_9_0_, setting0_.data_type as col_10_0_, setting0_.multiple as col_11_0_, setting0_.edit_mode as col_12_0_, setting0_.super_edit_mode as col_13_0_, setting0_.action_required as col_14_0_, setting0_.setting_configuration as col_15_0_, settingdef5_.default_value as col_16_0_ from currentds.icm_setting setting0_ left outer join currentds.icm_setting_value settingval1_ on setting0_.code=settingval1_.setting_code left outer join currentds.icm_user user2_ on settingval1_.user_id=user2_.id, currentds.icm_settings_group settingsgr3_, currentds.icm_setting_default_value settingdef5_ where setting0_.settings_group_id=settingsgr3_.id and setting0_.code=settingdef5_.setting_code and setting0_.setting_level=1 and (settingval1_.user_id=1 or settingval1_.user_id is null)

But the query I need is this

SELECT icm_user.id,*
FROM ICM_setting
     LEFT JOIN (
         icm_setting_value INNER JOIN icm_user ON icm_setting_value.user_id = icm_user.id
     ) ON ICM_setting.code = icm_setting_value.setting_code AND icm_setting_value.user_ID=1
     WHERE ICM_SETTING.SETTING_LEVEL=1

Any help?


Advertisement
View Answers

Related Tutorials/Questions & Answers:
Join problem with JPA Criteria Builder
Join problem with JPA Criteria Builder  I need to make this Query in criteria Builder. At this momento I?´m making it like this: Root<... join currentds.icm_setting_value settingval1_ on setting0_.code=settingval1
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
Advertisements
Hibernate Criteria Join
Hibernate Criteria Join API Hibernate Criteria JOIN API allows users to perform join operation. Suppose you have to perform a operation like SELECT S.*, C.... Read More about the restriction on Criteria. A Simple class of criteria join
Hibernate Criteria Join
query, one of them is Hibernate Criteria Join which performs join operation... and returns the value. Example of Hibernate Criteria join: SelectCriteria.java... Criteria Join Hibernate Criteria Examples
JPA
JPA  Sir, I have tried making the jpa application which you have given on this site . But then also I m facing problem in that like : If i make then also it is giving error. If I try to run the application provided by you
JPA
JPA  HOW CAN I WRITE A SIMPLE PROGRAM IN NETBEANS CONSOLE ON JPA ON CRUD APPLICATION? HOW CAN I START KINDLY HELP ME
JPA
JPA   I HAVE MADE A PROJECT IN I HAVE MADE ONE - ONE RELATION MY CODE IS ALSO RIGHT FROM MY POINT OF VIEW. AND WHEN I RUN IT IS GIVING ME THE MESSAGE AS BELOW::::::: run: [EL Info]: 2012-02-27 09:42:36.466--ServerSession
What is JPA 2.1?
What is JPA 2.1? What are the new features of JPA 2.1? This tutorial will introduce you with the JPA 2.1 specification. You will also learn the new features of the JPA 2.1. Java Persistence API Version 2.1 or JPA 2.1 is defined through
criteria
criteria in hibernate?   Here is a code that finds the maximum salary among the employees from the database using Hibernate Criteria. Criteria criteria... Criteria Query to find max salary
JPA 2.1 Tutorial
/Criteria enhancements - Now JPA 2.1 supports arithmetic sub-queries, generic...Learn the new features of JPA 2.1 and understand how to use the new features of JPA 2.1 The Java Persistence API Version 2.1 or simply JPA 2.1 is part of JEE
Join Point
Join Point  What is a join point in Spring
JPA Named Query
JPA Named Query       In this section, you will read about the JPA Query, its types and how to use the JPA Named Query in your JPA application. JPA Query is powerful
JPA Tutorial
JPA Tutorial In this section we will discuss about the Java Persistence API. This section will describe you all the aspects of JPA such as what is JPA, architecture of JPA, features of JPA, JPA entities, entity inheritance JPA, how
Application without Interface Builder!!
Application without Interface Builder!!  Can we make our iphone application without Interface Builder???   hello, yes , it is possible to make an iphone application without interface builder.. we can also use only
Hibernate 4.3 JPA 2.1
version of Hibernate is 4.3 and JPA is JPA 2.1. My problem is to write...Hibernate 4.3 JPA 2.1  How to create a Java program using Hibernate 4.3 JPA 2.1? I my project I have to use the latest version of Hibernate and JPA
Outer join
Outer join  hii, What is outer join? Types of outer join??   hello, There are two type of outer join:- A. Left Outer Join B. Right Outer Join The Left Outer Join returns all the rows from the Left Table
Is there a way to reuse builder code for retrofit
Is there a way to reuse builder code for retrofit  Is there a way to reuse builder code for retrofit
What is a "join"?
What is a "join"?  What is a "join"?   Hi, Here is the answer, The JOIN keyword is used in an SQL statement to query data from two.... Tables in a database are often related to each other with keys.A join is used
JPA Framework
JPA Framework  Hi, Can someone tell me about the JPA Framework..., you can get details about the JPA Framework with suitable examples on the below links. http://www.roseindia.net/jpa/eclipsejpaexamples/index.shtml You can visit
Using criteria for multiple tables
Using criteria for multiple tables  How to join more than three tables,those tables must be maintain primary key relation ship using Hql criteria & projections
Using criteria for multiple tables
Using criteria for multiple tables  How to join more than three tables,those tables must be maintain primary key relation ship using Hql criteria & projections
JPA CriteriaBuilder - How to use ?IN? comparison operator
of criteria builder? I need to filter by using list/array of usernames using "in". ***I also tried to search using JPA CriteriaBuilder - "in" method but cannot find...JPA CriteriaBuilder - How to use ?IN? comparison operator  Can you
Flex SDK vs Flash Builder
and Flash builder? please tell me about that.... Thanks   Ans: Flex SDK: Flex builder uses SDK to compile your data and create a swf. The SDK is free... program such as notepad. Flash Builder: Flash builder 4 and Flex Builder 3
Hibernate & JPA
Hibernate & JPA  What is difference between JPA and Hibernate ? Both of them look similar then what is the exact difference between them
Hibernate Criteria Examples
Hibernate Criteria Join Hibernate Criteria And Or Hibernate Criteria Order...Hibernate Criteria Examples In this section we are giving many example of using Hibernate Criteria query. With the help of criteria query you can
SQL Join
SQL Join       Mysql Join Mysql Join is used to join the records from two table using join clause. The Join Clause return you the set of records from both
When would you use the Builder Pattern?
When would you use the Builder Pattern?  When would you use the Builder Pattern
When would you use the Builder Pattern?
When would you use the Builder Pattern?  When would you use the Builder Pattern
Sigma Visusal Ajax UI builder
Sigma Visusal Ajax UI builder       Sigma visual builder is web based tool for AJAX RIA application UI... Linb), Sigma visual builder products great compatibilities with web browsers
Hibernate JPA
In this section, you will learn about JPA with Hibernate
JPA Relationship
JPA Relationship          In this section, you will know about the jpa relationship. JPA supports the relationship between entities. There are following types
Advertisements
 

 

 

DMCA.com