Magesh Lakshmi

Greenhorn
+ Follow
since Nov 02, 2005
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Magesh Lakshmi

Simplest way is to keep the hbm file along with the java file in the same package. Tyr it out.
Got the problem.
Instead of creating an transient Item instance, we should have used
sess.load() to first load the instance and then use if for querying.
Typical way is browse through the collection and collect it in your own collection [ probably DTO collection ] , close the session and send it to the client. This way, we can eliminate long lived sessions and its NOT a good idea to expose a middle-tier session to the front end objects, owing to many reasons [ highly coupled, expensive object on HTTPSESSION ]
I have a code like this.

List list = Collections.EMPTY_LIST;
sess = HibernateSessionFactory.currentSession();
Item item = new Item();
item.setItemName( itemName );

//WAY : 1
Query query = sess.getNamedQuery("findBidsForItem");
query.setEntity( "it", item );
list = query.list();

//WAY : 2
//Criteria criteria = sess.createCriteria( Item.class );
//criteria.add( Example.create( item ));
//list = criteria.list();


When i execute using WAY 1, I get this TransientObjectException, but when i execute it using WAY 2, everything works fine.

Can anyone please clarify this ?
Send me an email , if you need code samples on how to use this one.
Pro Spring is far better when you want to fiddle around with Spring, owing to the fact that there are lot of examples.

Especially AOP is explained , the way to be explained.
JDBC Vs ORM [ in particular Hibernate ]
---------------------------------------

1. Query by example [ Criterial queries ]
2. Substituting the whole object as parameter to the query
3. Ease of persisting dependency
4. Automapping of result set to objects
5. Pagination
6. Polymorphic queries
7. Implicit joins .. Eg bid.item.category
8. Detached persistence

Note :- JDBC is good at read-only data. So if you are planning to you projections in Hibernate, you should give a shot to JDBC first, definitely faster than projections.

and so many.
Frank,

If you use Hibernate + Spring [ most preferred combo ], then Spring has a JDBCTemplate, where in jdbc calls are much simplified. Even you can create an object directly out of the resultset, without you populating the object.
It would be highly appreciable if some one could explain the internals of hibernate in this context.
[ November 04, 2005: Message edited by: Magesh Lakshmi ]
Can anyone point out on these methods and its effect on the hibernate cache.
meaning, when hibernate would go to cache.

get()
find()
load()
iterate()

thanks,