-->
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: [Hibernate 5.1.0]Adding programmatically AttributeConverter
PostPosted: Wed Feb 24, 2016 12:35 pm 
Newbie

Joined: Wed Feb 24, 2016 12:21 pm
Posts: 5
I am migrating an application from Hibernate 4.3 to Hibernate 5.0.1-Final, and i have a issue with Adding programmatically our own AttributeConverter instance.
with Hibernate 4.3 the code used is:

Code:

public class CustomEntityManagerFactoryBuilder extends EntityManagerFactoryBuilderImpl {
...
@Override
    public Configuration buildHibernateConfiguration(ServiceRegistry serviceRegistry) {
        Configuration buildHibernateConfiguration = super.buildHibernateConfiguration(serviceRegistry);
        try {
            buildHibernateConfiguration.addAttributeConverter(converterWeakReference, true);
        } catch(Exception e) {
                      log.debug("", e);
        }
        return buildHibernateConfiguration;
    }
...
}


thanks!


Top
 Profile  
 
 Post subject: Re: [Hibernate 5.1.0]Adding programmatically AttributeConverter
PostPosted: Thu Feb 25, 2016 1:09 am 
Hibernate Team
Hibernate Team

Joined: Thu Sep 11, 2014 2:50 am
Posts: 1638
Location: Romania
You didn't mention the problem. Do you get an exception?

_________________
If you liked my answer, you are going to love my High-Performance Java Persistence book and my blog as well.


Top
 Profile  
 
 Post subject: Re: [Hibernate 5.1.0]Adding programmatically AttributeConverter
PostPosted: Thu Feb 25, 2016 4:22 am 
Newbie

Joined: Wed Feb 24, 2016 12:21 pm
Posts: 5
mihalcea_vlad wrote:
You didn't mention the problem. Do you get an exception?


the problem is the class EntityManagerFactoryBuilderImpl in hibernate 5.1.0 no longer have the method buildHibernateConfiguration(serviceRegistry), and i dont know how to migrate this code:
Code:
@Override
    public Configuration buildHibernateConfiguration(ServiceRegistry serviceRegistry) {
        Configuration buildHibernateConfiguration = super.buildHibernateConfiguration(serviceRegistry);
        try {
            buildHibernateConfiguration.addAttributeConverter(converterWeakReference, true);
        } catch(Exception e) {
                      log.debug("", e);
        }
        return buildHibernateConfiguration;
    }


Top
 Profile  
 
 Post subject: Re: [Hibernate 5.1.0]Adding programmatically AttributeConverter
PostPosted: Thu Feb 25, 2016 4:43 am 
Hibernate Team
Hibernate Team

Joined: Thu Sep 11, 2014 2:50 am
Posts: 1638
Location: Romania
This is how you bootstrap with Hibernate 5.
Code:
ServiceRegistry standardRegistry =
    new StandardServiceRegistryBuilder().build();

MetadataSources sources = new MetadataSources( standardRegistry );

MetadataBuilder metadataBuilder = sources.getMetadataBuilder();
metadataBuilder.applyAttributeConverter(attributeConverter);

Metadata metadata = metadataBuilder.build();

SessionFactory sessionFactory = metadata.getSessionFactoryBuilder()
    .applyBeanManager( getBeanManager() )
    .build();

_________________
If you liked my answer, you are going to love my High-Performance Java Persistence book and my blog as well.


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.