VenkataPrasad Regula

Ranch Hand
+ Follow
since Jun 30, 2011
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by VenkataPrasad Regula

It is not existing in the Session api, but it is existing Session facade api . The code is shown below
I would like to ask you "Is my question clear", because if not I would retype it again to make things clear..
The hibernate version I used was 4.1.2. I am not finding version 3 on hibernate website
I am working with interceptors in Hibernate. I am using the hibernate version 4. In the tutorials (almost all found on the net), they are passing the interceptor as a parameter to openSession() method as below
factory.openSession( new MyInterceptor() );

As i go to the eclipse and type the code it is not having that api which takes Interceptor as parameter for openSessionMethod. It is not even having object as parameter. Could someone guide me.
The answer to the above question is at the link www.coderanch.com/t/96328/Testing/handle-exception-JUnit-code
13 years ago
How do you write a testcase to test ArrayIndexOutOfBounds for an array in junit? Thanks in advance.
13 years ago
My task is to
1. Instantiate an object(a)
2. declare an other of the same class(b)
3. clone the object in step 1 to step 2(b=a.clone())
4. check if a and b are equal(a== b and a.equals(b))
5 Declare a hashset and add both a and b to the hashset.

Now my issues are as below
1. For Code 1 below HashSet is showing 1 as the count
2. For Code 2 below HashSet is showing 2 as the count.
Code1


Code 2
13 years ago
In any Hibernate tutorial we find the following steps

1. Create a Session Factory
2. Create a session
3. Do the unit of work
4. Close the session.

In an enterprise environment, we have the following issues as
1. How to create the session for different pages
2. If the page has multiple tasks to be done on a single page
3. If the result is returned to a page we return the POJO, which indicates the session will still be open. How to close the session
4. If the session is closed before return we cant return to the results page as the whole conversation gets closed by session.close()


When you write a junit test methods code, does it catch checked exception or unchecked exception?
13 years ago
As I try to start glassfish from myeclipse I am getting the following error

Exception in thread "main" java.lang.NoClassDefFoundError: com/sun/enterprise/glassfish/bootstrap/ASMain
Caused by: java.lang.ClassNotFoundException: com.sun.enterprise.glassfish.bootstrap.ASMain
at java.net.URLClassLoader$1.run(URLClassLoader.java:217)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:205)
at java.lang.ClassLoader.loadClass(ClassLoader.java:321)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294)
at java.lang.ClassLoader.loadClass(ClassLoader.java:266)
Could not find the main class: com.sun.enterprise.glassfish.bootstrap.ASMain. Program will exit.
As i start glassfish from myeclipse I am getting the following error. Can someone please kindly look into it.

Exception in thread "main" java.lang.NoClassDefFoundError: com/sun/enterprise/glassfish/bootstrap/ASMain
Caused by: java.lang.ClassNotFoundException: com.sun.enterprise.glassfish.bootstrap.ASMain
at java.net.URLClassLoader$1.run(URLClassLoader.java:217)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:205)
at java.lang.ClassLoader.loadClass(ClassLoader.java:321)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294)
at java.lang.ClassLoader.loadClass(ClassLoader.java:266)
Could not find the main class: com.sun.enterprise.glassfish.bootstrap.ASMain. Program will exit.
13 years ago
I have an abstract class and two concrete class which extend these abstract class. I have mapped all the three in a employee.hbm.xml file. It is throwing the following error. My db is mysql

Exception in thread "main" org.hibernate.NonUniqueObjectException: a different object with the same identifier value was already associated with the session: [temp.ContractEmployee#0]

.
Could someone kindly look into it.

Abstract Class


Extended Class 1

Extended Class 2


MainClass

employee.hbm.xml file



The issue is resolved. I have added session.flush() before session.close(). Now the data is displayed.
I wrote a sample Hibernate code to insert data, by looking at one of the tutorials found on google. Interesting thing is as I open MySQL sql editor, I am finding the column names but the data is not found. I am struggling with it since two days.My issues are
1. Data is not being displayed on mysql sql editor. I tried the same with postgres too. The same issue.
2. I have given show_sql as true in hibernate.cfg.xml file, I am not able to see the sql query


As I have put the debugger statements, I am able to see all the statements as below

Environment

OS: Ubuntu
Database: MySQL
ORM tool: Hibernate
IDE eclipse

My issue got resolved the change I have done is as follows

Session session = sessionFactory.getCurrentSession(); //Earlier I was using

Session session = sessionFactory.openSession(); //I changed the above line to this as shown

Now it is working fine.