-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 
Author Message
 Post subject: NIgration from Hibernate 3.2 to 4.2
PostPosted: Mon Dec 16, 2013 7:28 am 
Newbie

Joined: Mon Dec 16, 2013 7:20 am
Posts: 2
HI

I am new to Hibernate but have been tasked to migrate from 3.2 to 4.2. I am having problems with class/methods not found. Typically getSession, TransactionHelper, SessionFactoryImplementor, PropertiesHelper.

If these are no longer available in version 4.2 what do I replace the above with.

Thanks Andy


Top
 Profile  
 
 Post subject: Re: NIgration from Hibernate 3.2 to 4.2
PostPosted: Mon Dec 16, 2013 10:21 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 3:00 pm
Posts: 1816
Location: Austin, TX
That's a big jump.

Not sure what getSession call you mean.

You'd gave to remind me what TransactionHelper useds to be/do and how you use it.

SessionFactoryImplementor is still there. org.hibernate.engine.spi.SessionFactoryImplementor

PropertiesHelper, I think you'd want org.hibernate.internal.util.config.ConfigurationHelper


Top
 Profile  
 
 Post subject: Re: NIgration from Hibernate 3.2 to 4.2
PostPosted: Tue Dec 17, 2013 5:46 am 
Newbie

Joined: Mon Dec 16, 2013 7:20 am
Posts: 2
Hi Thanks for the help much appreciated.

Transaction helper used to be in org.hibernate.engine.TransactionHelper

the method required is doWorkinNewTransaction

getSession() is a method used in 3... which I also believe was in hibernate.engine but now has dissappeared.

line of code is
Session session = this.getCurrentSession().getSession(EntityMode.MAP);


Top
 Profile  
 
 Post subject: Re: NIgration from Hibernate 3.2 to 4.2
PostPosted: Wed Dec 18, 2013 10:26 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 3:00 pm
Posts: 1816
Location: Austin, TX
andyrus wrote:
Transaction helper used to be in org.hibernate.engine.TransactionHelper

the method required is doWorkinNewTransaction


This concept is now handled non-statically by org.hibernate.engine.transaction.spi.IsolationDelegate which is varied for you based on the underlying transaction mechanism. ATM I do not expose this via any of the APIs, it is however accessible via SPIs:
Code:
org.hibernate.spi.SessionImplementor sessionSpi = (org.hibernate.spi.SessionImplementor) session;
sessionSpi.getTransactionCoordinator().getTransaction().createIsolationDelegate().delegateWork(
        new org.hibernate.jdbc.AbstractWork() {
            @Override
            public void execute(Connection connection) throws SQLException {
                // do your work here, knowing you are in a new transaction
            }
        },
        true
);


There is also a form of Work returning a value, ReturningWork:
Code:
org.hibernate.spi.SessionImplementor sessionSpi = (org.hibernate.spi.SessionImplementor) session;
Integer someValue = sessionSpi.getTransactionCoordinator().getTransaction().createIsolationDelegate().delegateWork(
        new org.hibernate.jdbc.AbstractReturningWork<Integer>() {
            @Override
            public Integer execute(Connection connection) throws SQLException {
                // do your work here, knowing you are in a new transaction
                return someIntegerValue;
            }
        },
        true
);


andyrus wrote:
getSession() is a method used in 3... which I also believe was in hibernate.engine but now has dissappeared.

line of code is
Session session = this.getCurrentSession().getSession(EntityMode.MAP);


The ability to mix entitymodes *for an entity* within a Session/SessionFactory is removed. Within a SessionFactory an entity is either POJO or MAP.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.