Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 4 of 4

Thread: Stale Object exception

  1. #1
    Junior Member
    Join Date
    Aug 2014
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Stale Object exception

    Hi All,
    Caused by: javax.persistence.NonUniqueResultException: result returns more than one elements
    at org.hibernate.ejb.QueryImpl.getSingleResult(QueryI mpl.java:109)


    What are the common reasons for the above exception and the suitable fixes? Can u please list some


    Thank you,
    Good day!


  2. #2
    Super Moderator
    Join Date
    Jun 2013
    Location
    So. Maryland, USA
    Posts
    6,346
    My Mood
    Mellow
    Thanks
    254
    Thanked 784 Times in 769 Posts

    Default Re: Stale Object exception

    Welcome to the forum! Please read this topic to learn how to post code in code or highlight tags and other useful info for new members.

  3. #3
    Member Ada Lovelace's Avatar
    Join Date
    May 2014
    Location
    South England UK
    Posts
    411
    My Mood
    Angelic
    Thanks
    27
    Thanked 61 Times in 55 Posts

    Default Re: Stale Object exception

    Not 100% on this, but in general when a method returns it can
    only return one value, not multiple values. A method can have more
    than one route of returning, but only single data items can be returned
    with the return statement.

    This is valid:

    public int addMe() {
        return sum;
    }
     
    This is not:
     
    public int addMe() {
        return sum, division, subtraction;
    }
    If to Err is human - then programmers are most human of us all.
    "The Analytical Engine offers a new, a vast, and a powerful language . . .
    for the purposes of mankind
    ."
    Augusta Ada Byron, Lady Lovelace (1851)

  4. #4
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,372
    Thanks
    184
    Thanked 836 Times in 779 Posts
    Blog Entries
    5

    Default Re: Stale Object exception

    Did you read the API for that exception?
    NonUniqueResultException (Java EE 5 SDK)
    The query you are using returns more than one result. Change the data to reflect your query (eg make it a single result), or change the query to reflect the data (use a different method to collect more than one result)

Similar Threads

  1. Exception while reading JSON object
    By swarna in forum Java Theory & Questions
    Replies: 4
    Last Post: February 21st, 2013, 12:33 AM
  2. Exception while reading JSON object
    By swarna in forum What's Wrong With My Code?
    Replies: 0
    Last Post: February 20th, 2013, 03:21 PM
  3. nullpointer exception when adding Object to ArrayList
    By bartolio in forum What's Wrong With My Code?
    Replies: 14
    Last Post: January 20th, 2013, 12:17 PM
  4. DataSource null pointer exception from object
    By jyounger in forum JDBC & Databases
    Replies: 0
    Last Post: February 20th, 2012, 05:44 AM

Tags for this Thread