This week's book giveaway is in the Functional programming forum.
We're giving away four copies of A Functional Approach to Java: Augmenting Object-Oriented Java Code with Functional Principles and have Ben Weidig on-line!
See this thread for details.

Naresh Chaurasia

Ranch Hand
+ Follow
since May 18, 2005
Merit badge: grant badges
For More
Cows and Likes
Total received
In last 30 days
Total given
Total received
Received in last 30 days
Total given
Given in last 30 days
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Naresh Chaurasia

Why is the output of following program negative.

The output is -2147483648
8 years ago
I mean in String array, I should be only allowed to search for String, and not integers
8 years ago
I came across the following statement in Java SCJP 6.0 Khalid Mughal.

Note that we can only add an object of a specific type (E). However, a collection
allows us to determine whether it has an element equal to any arbitrary object,
or remove an element that is equal to any arbitrary object.

I tried the following program.

I am not clear as to why the Generics allow Searching/Removing arbitrary object, when in the above case it can only store String.

Please advise.
8 years ago
I have following working code for jdbc automatic resource management.

Does the resource management also work for hibernate session object.
8 years ago
I have following code:

Why does it fail at System.out.println(node2.getO()), since i am making it clear at line MyNode <String> node2 = new <String> MyNode(10) that it will accept only String, why does it allow me to pass Integer 10 in the constructor.
8 years ago
I understand that creation of session factory is expensive operation. Now assuming that i have an application1 with 10 java bean that are persisted in db and application2 with 100 java beans to be persisted.

In the application1 hibernate1.cfg.xml i have specified the mapping of all the 10 java bean and in application2 hibernate2.cfg.xml i have specified the mapping of all the 100 java beans.

Now in application1, i create a session factory sf1 and in application2 i create a session factory sf2.

Does creation of sf1 requires same amount of resources and is as "expensive" as creation of sf2.

I am trying to figure this out as i have multiple db instance, and multiple session factories are created. I want to merge all these db instance to reduce the overhead of creation of multiple session factories.

Please advise
I have a working project for spring XA transaction ( I modified the project downloaded and created pom.xml since i had to integrate it with my project. Initially i started with spring 3x. I got it working properly for spring 3x. Now i have to integrate it with hibernate, so in order to create hibernate session factory, i stated migrating it to spring 4x.

i have following entries in my config file for spring 3x

spring config file:

and the pom.xml is having following entry:

This works completely fine. Now if i want to migrate to spring4x, i make the following changes and update my pom.xml as follows:

When i make the above changes and run my program, i get the following error:

Is there any other changes i have to make to get this project working with spring 4x.

I am trying to migrate to spring 4x since i have to make session factory as follows:

I have put my code at . If you open the rar, the root folder contains MainApp.log. Also there is lib folder containing 3 jars which are required by application. The other jars can be downloaded by using pom.xml.
9 years ago
Hi Folks, I have 10+ extensive java/j2ee experience. I am looking forward to enhancing my skills. Big data/MongoDB is making new and hot in market. I want to learn new skills, but what are the benefits and how does it help in my current market.

Experts please advice.
9 years ago
I have following code:

Even thought i have set @Transactional(readOnly = true) for insert method, still the insert operation is being performed. Should not the attribute readOnly, which is set to true should take care that insert cannot be performed on this method.
9 years ago
It is a web application. Make sure that the hibernate.cfg.gwt.xml and .class files are in classes folder inside the WEB-INF folder. Try to create structure as follows:
After a lot of R&D, I used the following link to get me started on spring jpa.

I used the following gradle file to download all the dependencies:

9 years ago

In case i uncomment line2 the following query is fired irrespective of fetch as {select|join}

System.out.println("not null"); //line1
System.out.println(e2.getFirstname()); //line2
I have following code:

I am setting fetch as {select|join}. In both cases the get the following output in the following loop:

System.out.println("not null"); //line1
//System.out.println(e2.getFirstname()); //line2

and no select query is being fired on db.

My understanding is that in case of fetch="select", the proxy is loaded so the select query is not being fired. But in case fetch="join" eager loading should take place and select query should be fired immediately when instance is loaded from session. In none of the cases no selet query if fired.

Please clarify. Thanks.
I am having following code:

I have the following ejb-jar.xml

I have ear with following structure:

The mdbExample.jar contains the ejb.
e-store is web application calling the ejb.
I have put ejb-jar.xml inside META-INF.

Also i have updated the D:\TranscendingCode\jboss-5.1.0.GA\server\default\deploy\messaging\messaging-service.xml with the following entry:

when i run the following command: jar tf mdb.ear i get the below output


When i try to deploy the mdb.ear i get the following error:

I came across following statement:

Second level cache is an optional cache and first-level cache(session) will always be consulted before any attempt is made to locate an object in the second-level cache.

Suppose i have enabled 2nd level cache, using EHCache. Now i save an object O by saying The object O is stored in session. Will it also be stored in second level cache.

Thanks in advance.