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

  • SEARCH
  • Home
  • 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 6039313
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T06:21:00+00:00 2026-05-23T06:21:00+00:00

i am making a sample program in hibernate follow this tutorial: http://www.myeclipseide.com/documentation/quickstarts/hibernateintroduction/ using reverse

  • 0

i am making a sample program in hibernate follow this tutorial:
http://www.myeclipseide.com/documentation/quickstarts/hibernateintroduction/

using reverse engineering, i have created this method.
EventsDAO.java:

public Events findById(com.hibernate.EventsId i) {
    log.debug("getting Events instance with id: " + i);
    try {
        Events instance = (Events) getSession().get(
                "com.hibernate.Events", i);
        return instance;
    } catch (RuntimeException re) {
        log.error("get failed", re);
        throw re;
    }
}

and calling from main class makiing this method:

private static void listEvents()
{
    EventsDAO dao= new EventsDAO();
    Events events= dao.findById(1);
    printEvents("Printing User,", events);
dao.getSession().close();
}

it give me error on : Events events= dao.findById(1);
because here, i am passing int. and in EventsDAO.java, its type is EventsID.

please suggest.

as surlac suggest,
now it is giving exception:
Exception in thread “main” org.hibernate.id.IdentifierGenerationException: ids for this class must be manually assigned before calling save(): com.hibernate.Events

private static void addEvents()
{
    Events events= new Events();
    events.setUid(1);
    events.setName("abc");
    events.setDuration(123);
    EventsDAO dao= new EventsDAO();
    Transaction tx=dao.getSession().beginTransaction();
dao.save(events);
tx.commit();
dao.getSession().close();
}

it is giving exception on this line:

dao.save(events);

Here is Events.hbm.xml file: <?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<!--
Mapping file autogenerated by MyEclipse Persistence Tools
-->
<hibernate-mapping>
<class name="com.hibernate.Events" table="EVENTS" schema="APP">
<composite-id name="id" class="com.hibernate.EventsId">
<key-property name="uid" type="java.lang.Long">
<column name="UID" />
</key-property>
<key-property name="name" type="java.lang.String">
<column name="NAME" length="20" />
</key-property>
<key-property name="duration" type="java.lang.Integer">
<column name="DURATION" />
</key-property>
</composite-id>
</class>
</hibernate-mapping>

please help.

  • 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-05-23T06:21:00+00:00Added an answer on May 23, 2026 at 6:21 am

    Try to use Integer as an ID, unless you use composite keys:

        public Events findById( java.lang.Integer id) {
            log.debug("getting Events instance with id: " + id);
            try {
                Events instance = (Events) getSession()
                        .get("com.hibernate.Events", id);
                return instance;
            } catch (RuntimeException re) {
                log.error("get failed", re);
                throw re;
            }
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm making simple webcam program using OpenCV 2.3 and got stuck by the compile
I'm making simple webcam program using OpenCV 2.3 and got stuck by the runtime
If something is making a single-thread program take, say, 10 times as long as
this question is from Codechef.com [if anyone is still solving this question dont look
I'm making a simple cart program in php. What the code below does is
I'm making a relatively simple program which will also be running on a few
I'm making a very simple WCF (C#, .NET 4.0) licensing program that automatically emails
This should be simple, I need to stop any previous version of my program
This is beyond both making sense and my control. That being said here is
now.. I was making a program.. but I want to make the program connected

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.