0

I used old JPA so that I can use code as below:

JpaProperties jpaProerties;
EntityManagerFactoryBuilder(jpaVendorAdapter, jpaProperties, persistenceUnitManager)

Now it is deprecated so I want to change it to

JpaProperties jpaProerties;
EntityManagerFactoryBuilder(JpaVendorAdapter, jpaProerties.getProperties(), PersistenceUnitManager)

But I got error as below:

The method EntityManagerFactoryBuilder(JpaVendorAdapter, Map<String,String>, PersistenceUnitManager) is undefined

I don't know why Map<String, String> can't used for Map<String, ?> later is wild and all objects should be used, May I make sense? How can I do to slove it? Here is my code :

import org.springframework.boot.orm.jpa.EntityManagerFactoryBuilder;

@Bean
@ConfigurationProperties("app.master.jpa")
public JpaProperties masterJpaProperties() {
    return new JpaProperties();
}

@Bean
public LocalContainerEntityManagerFactoryBean masterEntityManager() {
    JpaVendorAdapter jpaVendorAdapter = new HibernateJpaVendorAdapter();

    EntityManagerFactoryBuilder builder = EntityManagerFactoryBuilder(jpaVendorAdapter, masterJpaProperties.getProperties(), this.persistenceUnitManager);

    return builder
            .dataSource(masterDataSource())
            .packages(Customer.class)
            .persistenceUnit("masters")
            .build();
}

The error is

Multiple markers at this line
- The method EntityManagerFactoryBuilder(JpaVendorAdapter, Map<String,String>, PersistenceUnitManager) is undefined for the 
 type MasterConfiguration
- The method EntityManagerFactoryBuilder(JpaVendorAdapter, Map<String,capture#1-of ?>, PersistenceUnitManager) is undefined 
 for the type MasterConfiguration
mikezang
  • 2,291
  • 7
  • 32
  • 56
  • The `?` does not mean "all objects"; it means "objects of some specific but unspecified type". If you want "all objects", use `Object`. – Ted Hopp Jan 22 '16 at 04:10
  • I don't need all objects:)(: I just want to use EntityManageFactoryBuilder, can you tell me how to convert old Map properties to new Map ? – mikezang Jan 22 '16 at 05:23
  • If I cast it that I got code Map, what does it be different from Map – mikezang Jan 22 '16 at 05:39
  • See https://gist.github.com/jnizet/dfb0ffa8fa7bdec29b18: that compiles perfectly. So, the error is not what you think it is. We have no idea what the EntityManagerFactoryBuilder class is, and you didn't post the relevant code, so we can't help. – JB Nizet Jan 22 '16 at 08:16
  • Yeah, your source is ok even in my eclipse! But that not my case because your made that class, I am using class from JPA... I will add source to my question. – mikezang Jan 22 '16 at 08:34
  • Have you thought Map to Map? – ViRALiC Jan 22 '16 at 08:49
  • I got answer! because I omit new in that line:( Sorry for this misstake! – mikezang Jan 22 '16 at 08:54
  • Thanks a lot that I can slove it! – mikezang Jan 22 '16 at 09:12

0 Answers0