Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7842921
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T16:25:54+00:00 2026-06-02T16:25:54+00:00

here is a snippet of my entity (it also has hashcode and equals created

  • 0

here is a snippet of my entity (it also has hashcode and equals created which are the default ones generated by java

@Entity 
@Table(name = "media_tspec_external_registry")
public class Registry implements Serializable {


public Registry() {
    //for hibernate :D
}



public Registry(String show, String protocol, String externalEndpoint, String userURI, String version) {
    super();
    this.show = show;
    this.protocol = protocol;
    this.externalEndpoint = externalEndpoint;
    this.userURI = userURI;
    this.version = version;
}




@Id
@Column(name = "show", nullable = false)
private String show;

@Id
@Column(name = "protocol", nullable = false)
private String protocol;

@Column(name = "external_endpoint", nullable = true)
private String externalEndpoint;

here is my method which is trying to load an entity which does not exist, based on these key values

Registry reg = new Registry("invalid", "idvalue", null, null, null);
    Registry reg2 = null;
    try {

        reg2 = (Registry) session.load(Registry.class, reg);
             } catch (HibernateException e) {
        throw new UserException("A registry entry does not exist for this show: " + show + " and protocol: " + protocol);
        }

it never throws the exception and reg2 is now set to a registry object with all the fields set to null.

i have also noted that the load will not even load a existing entity.

however if i use get instead it works as expected (loading valid object returning null for non existing objects)

reg2 = (Registry) session.get(Registry.class, reg);

any explanation would be appreciated.

Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T16:25:55+00:00Added an answer on June 2, 2026 at 4:25 pm

    this is expected behavior. session.load is meant to get an object which can be used to satisfy references, e.g.

    User u = new User();
    u.setRole((Role)session.load(Role.class, 5));
    session.save(u);
    

    load will not generate a roundtrip. If there is no reference to the object available it will create a proxyobject or in your case will recycle your compositekey object and relies on you that the entity exists since it can not ask the database if it is so.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We use spring to construct/inject our java beans. Here a snippet: <bean id=myAppConfigs class=my.cool.webapp.ApplicationConfig
Here's the setup: the entity class has the collection of other entities that is
I found this snippet here. $resttimefrom = 50000; // 5am $resttimeto = 170000; //
Here is a snippet kit.insertHTML(doc, doc.getLength(), Hello, 0, 0, null); try{ Thread.sleep(1000); }catch(Exception e){}
Here's a snippet that I use to parse options in Bash: #!/bin/bash PROGNAME=${0##*/} PROGVERSION=0.1
Here is a snippet of my code: <?php if (!defined('BASEPATH')) { exit('No direct script
Here's a snippet from my application: class PortolioItem(models.Model): ... user = models.ForeignKey(User) contract =
Here's a snippet of a script of mine attempting to put extra Unicode awesomeness
Here is a snippet of the official Apple Documentation of AudioBufferList (Core Audio Data
Here is a snippet of my code $fp = fsockopen($s['url'], 80, $errno, $errstr, 5);

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.