Skip to content

Commit 0987f52

Browse files
alimateEugen
authored andcommitted
BAEL-2306: Update Spring JNDI article (eugenp#5540)
1 parent 84ef2cd commit 0987f52

2 files changed

Lines changed: 7 additions & 13 deletions

File tree

‎persistence-modules/spring-jpa/src/main/java/org/baeldung/config/PersistenceJNDIConfig.java‎

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,23 +23,19 @@
2323

2424
@Configuration
2525
@EnableTransactionManagement
26-
@PropertySource({ "classpath:persistence-jndi.properties" })
27-
@ComponentScan({ "org.baeldung.persistence" })
26+
@PropertySource("classpath:persistence-jndi.properties")
27+
@ComponentScan("org.baeldung.persistence")
2828
@EnableJpaRepositories(basePackages = "org.baeldung.persistence.dao")
2929
public class PersistenceJNDIConfig {
3030

3131
@Autowired
3232
private Environment env;
3333

34-
public PersistenceJNDIConfig() {
35-
super();
36-
}
37-
3834
@Bean
3935
public LocalContainerEntityManagerFactoryBean entityManagerFactory() throws NamingException {
4036
final LocalContainerEntityManagerFactoryBean em = new LocalContainerEntityManagerFactoryBean();
4137
em.setDataSource(dataSource());
42-
em.setPackagesToScan(new String[] { "org.baeldung.persistence.model" });
38+
em.setPackagesToScan("org.baeldung.persistence.model");
4339
em.setJpaVendorAdapter(new HibernateJpaVendorAdapter());
4440
em.setJpaProperties(additionalProperties());
4541
return em;
@@ -52,9 +48,7 @@ public DataSource dataSource() throws NamingException {
5248

5349
@Bean
5450
public PlatformTransactionManager transactionManager(final EntityManagerFactory emf) {
55-
final JpaTransactionManager transactionManager = new JpaTransactionManager();
56-
transactionManager.setEntityManagerFactory(emf);
57-
return transactionManager;
51+
return new JpaTransactionManager(emf);
5852
}
5953

6054
@Bean

‎persistence-modules/spring-jpa/src/main/java/org/baeldung/persistence/model/Foo.java‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public Foo(final String name) {
2525
@Id
2626
@GeneratedValue(strategy = GenerationType.AUTO)
2727
@Column(name = "ID")
28-
private long id;
28+
private Long id;
2929
@Column(name = "NAME")
3030
private String name;
3131

@@ -41,11 +41,11 @@ public void setBar(final Bar bar) {
4141
this.bar = bar;
4242
}
4343

44-
public long getId() {
44+
public Long getId() {
4545
return id;
4646
}
4747

48-
public void setId(final int id) {
48+
public void setId(final Long id) {
4949
this.id = id;
5050
}
5151

0 commit comments

Comments
 (0)