How to set a criteria with child table Unicorn Meta Zoo #1: Why another podcast? Announcing the arrival of Valued Associate #679: Cesar Manara Data science time! April 2019 and salary with experience The Ask Question Wizard is Live!Hibernate Criteria Join with 3 TablesGet list of all tables in Oracle?Hibernate criteria: Joining table without a mapped associationWrong ordering in generated table in jpaCriteria query whith FROM clause which contains only one query and does not contain any tablesHibernate Criteria Api SubqueriesCreate the perfect JPA entityCriteria: ClassCastException Integer to LongCount rows using criteria and projectionHow to convert this criteria code into CriteriaBuilder

Additive group of local rings

My admission is revoked after accepting the admission offer

What's parked in Mil Moscow helicopter plant?

How to use @AuraEnabled base class method in Lightning Component?

Function to calculate red-edgeNDVI in Google Earth Engine

What is /etc/mtab in Linux?

All ASCII characters with a given bit count

Can I criticise the more senior developers around me for not writing clean code?

Is Diceware more secure than a long passphrase?

Is accepting an invalid credit card number a security issue?

Map material from china not allowed to leave the country

Is Bran literally the world's memory?

Do I need to protect SFP ports and optics from dust/contaminants? If so, how?

What if Force was not Mass times Acceleration?

std::is_constructible on incomplete types

Why is this method for solving linear equations systems using determinants works?

Would reducing the reference voltage of an ADC have any effect on accuracy?

Does Feeblemind produce an ongoing magical effect that can be dispelled?

Why didn't the Space Shuttle bounce back into space as many times as possible so as to lose a lot of kinetic energy up there?

The art of proof summarizing. Are there known rules, or is it a purely common sense matter?

How to translate "red flag" into Spanish?

What is the ongoing value of the Kanban board to the developers as opposed to management

"My boss was furious with me and I have been fired" vs. "My boss was furious with me and I was fired"

What *exactly* is electrical current, voltage, and resistance?



How to set a criteria with child table



Unicorn Meta Zoo #1: Why another podcast?
Announcing the arrival of Valued Associate #679: Cesar Manara
Data science time! April 2019 and salary with experience
The Ask Question Wizard is Live!Hibernate Criteria Join with 3 TablesGet list of all tables in Oracle?Hibernate criteria: Joining table without a mapped associationWrong ordering in generated table in jpaCriteria query whith FROM clause which contains only one query and does not contain any tablesHibernate Criteria Api SubqueriesCreate the perfect JPA entityCriteria: ClassCastException Integer to LongCount rows using criteria and projectionHow to convert this criteria code into CriteriaBuilder



.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








0















I need to have query like this:



select * from TABLE where Source_KEY in (1,2);


My Hibernate class is like this:



@Entity
@Table(name = "TABLE", schema = "SCH")
public class Table
private Long key;
private Long id;
private Source src;


Source is another entity class,
@Entity
@Table(name = "SOURCE", schema = "SCH")
public class Source
private Long Source_KEY;



Now i have written a criteria but it seems to have an issue.
Please can anyone advice on this.



private static final List<String> STAY_SOURCE_KEY = asList(1,2);

criteria.add(Restrictions.in("Source_KEY", STAY_SOURCE_KEY));


This should be a list of Source class but how to to that in criteria. It has
to form query like



select * from TABLE where Source_KEY in (1,2);









share|improve this question
























  • Possible duplicate of Hibernate Criteria Join with 3 Tables

    – Peter Šály
    Mar 23 at 22:30

















0















I need to have query like this:



select * from TABLE where Source_KEY in (1,2);


My Hibernate class is like this:



@Entity
@Table(name = "TABLE", schema = "SCH")
public class Table
private Long key;
private Long id;
private Source src;


Source is another entity class,
@Entity
@Table(name = "SOURCE", schema = "SCH")
public class Source
private Long Source_KEY;



Now i have written a criteria but it seems to have an issue.
Please can anyone advice on this.



private static final List<String> STAY_SOURCE_KEY = asList(1,2);

criteria.add(Restrictions.in("Source_KEY", STAY_SOURCE_KEY));


This should be a list of Source class but how to to that in criteria. It has
to form query like



select * from TABLE where Source_KEY in (1,2);









share|improve this question
























  • Possible duplicate of Hibernate Criteria Join with 3 Tables

    – Peter Šály
    Mar 23 at 22:30













0












0








0








I need to have query like this:



select * from TABLE where Source_KEY in (1,2);


My Hibernate class is like this:



@Entity
@Table(name = "TABLE", schema = "SCH")
public class Table
private Long key;
private Long id;
private Source src;


Source is another entity class,
@Entity
@Table(name = "SOURCE", schema = "SCH")
public class Source
private Long Source_KEY;



Now i have written a criteria but it seems to have an issue.
Please can anyone advice on this.



private static final List<String> STAY_SOURCE_KEY = asList(1,2);

criteria.add(Restrictions.in("Source_KEY", STAY_SOURCE_KEY));


This should be a list of Source class but how to to that in criteria. It has
to form query like



select * from TABLE where Source_KEY in (1,2);









share|improve this question
















I need to have query like this:



select * from TABLE where Source_KEY in (1,2);


My Hibernate class is like this:



@Entity
@Table(name = "TABLE", schema = "SCH")
public class Table
private Long key;
private Long id;
private Source src;


Source is another entity class,
@Entity
@Table(name = "SOURCE", schema = "SCH")
public class Source
private Long Source_KEY;



Now i have written a criteria but it seems to have an issue.
Please can anyone advice on this.



private static final List<String> STAY_SOURCE_KEY = asList(1,2);

criteria.add(Restrictions.in("Source_KEY", STAY_SOURCE_KEY));


This should be a list of Source class but how to to that in criteria. It has
to form query like



select * from TABLE where Source_KEY in (1,2);






oracle hibernate criteria






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 22 at 16:05









Pavel Smirnov

2,5711818




2,5711818










asked Mar 22 at 15:55









RahulRahul

3010




3010












  • Possible duplicate of Hibernate Criteria Join with 3 Tables

    – Peter Šály
    Mar 23 at 22:30

















  • Possible duplicate of Hibernate Criteria Join with 3 Tables

    – Peter Šály
    Mar 23 at 22:30
















Possible duplicate of Hibernate Criteria Join with 3 Tables

– Peter Šály
Mar 23 at 22:30





Possible duplicate of Hibernate Criteria Join with 3 Tables

– Peter Šály
Mar 23 at 22:30












1 Answer
1






active

oldest

votes


















1














You need to join table. Use



criteria.createAlias("src","s");
criteria.add(Restrictions.in("s.Source_KEY", STAY_SOURCE_KEY));





share|improve this answer

























    Your Answer






    StackExchange.ifUsing("editor", function ()
    StackExchange.using("externalEditor", function ()
    StackExchange.using("snippets", function ()
    StackExchange.snippets.init();
    );
    );
    , "code-snippets");

    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "1"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader:
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    ,
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );













    draft saved

    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55303456%2fhow-to-set-a-criteria-with-child-table%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    1














    You need to join table. Use



    criteria.createAlias("src","s");
    criteria.add(Restrictions.in("s.Source_KEY", STAY_SOURCE_KEY));





    share|improve this answer





























      1














      You need to join table. Use



      criteria.createAlias("src","s");
      criteria.add(Restrictions.in("s.Source_KEY", STAY_SOURCE_KEY));





      share|improve this answer



























        1












        1








        1







        You need to join table. Use



        criteria.createAlias("src","s");
        criteria.add(Restrictions.in("s.Source_KEY", STAY_SOURCE_KEY));





        share|improve this answer















        You need to join table. Use



        criteria.createAlias("src","s");
        criteria.add(Restrictions.in("s.Source_KEY", STAY_SOURCE_KEY));






        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Mar 24 at 7:17

























        answered Mar 23 at 22:33









        Peter ŠályPeter Šály

        2,0852822




        2,0852822





























            draft saved

            draft discarded
















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid


            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.

            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55303456%2fhow-to-set-a-criteria-with-child-table%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

            Swift 4 - func physicsWorld not invoked on collision? The Next CEO of Stack OverflowHow to call Objective-C code from Swift#ifdef replacement in the Swift language@selector() in Swift?#pragma mark in Swift?Swift for loop: for index, element in array?dispatch_after - GCD in Swift?Swift Beta performance: sorting arraysSplit a String into an array in Swift?The use of Swift 3 @objc inference in Swift 4 mode is deprecated?How to optimize UITableViewCell, because my UITableView lags

            Access current req object everywhere in Node.js ExpressWhy are global variables considered bad practice? (node.js)Using req & res across functionsHow do I get the path to the current script with Node.js?What is Node.js' Connect, Express and “middleware”?Node.js w/ express error handling in callbackHow to access the GET parameters after “?” in Express?Modify Node.js req object parametersAccess “app” variable inside of ExpressJS/ConnectJS middleware?Node.js Express app - request objectAngular Http Module considered middleware?Session variables in ExpressJSAdd properties to the req object in expressjs with Typescript