File tree Expand file tree Collapse file tree
persistence-modules/spring-jpa/src/main/java/org/baeldung Expand file tree Collapse file tree Original file line number Diff line number Diff line change 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" )
2929public 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
Original file line number Diff line number Diff 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
You can’t perform that action at this time.
0 commit comments