Scale up as you grow — whether you're running one virtual machine or ten thousand.

From GPU-powered inference and Kubernetes to managed databases and storage, get everything you need to build, scale, and deploy intelligent applications.

Thank you for this example Dániel! In main class if we use Autowired annotation for ProductService productService does it work? Or if we move ProductService to another class which will be created after this line executed: ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext(“classpath:/spring.xml”); If not, I guess we have to use ctx whenever Spring beans are required. Regards.
- ismail
Exception in thread “main” javax.persistence.TransactionRequiredException: No EntityManager with actual transaction available for current thread - cannot reliably process ‘persist’ call at org.springframework.orm.jpa.SharedEntityManagerCreator$SharedEntityManagerInvocationHandler.invoke(SharedEntityManagerCreator.java:278) at com.sun.proxy.$Proxy8.persist(Unknown Source) at com.dao.ProductDao.Persist(ProductDao.java:19) at com.service.ProductService.add(ProductService.java:19) at SpringOrmMain.main(SpringOrmMain.java:22)
- Mithilesh
Exception in thread “main” java.lang.NoClassDefFoundError: antlr/RecognitionException This lib is into hibernate .jar, but the application don’t recognizes…
- Rodrigo Marini
Since you defined @PersistenceContext in ProductDao, every method will be there own transaction. So why to define @Transactional on method of ProductService ?
- Simron
NICE ONE. if we have an association, it will be different let me take a example in your Product Class let say we have set Of customers ------------------------------- @Entity public class Product { @Id private Integer id; private String name; @OneToMany(fetch type LAZY) set cust= new HashSet(0); // set and get } WE HAVE DAO METHOD LIKE THIS PUBLIC Set getCustomerstBasedOnProductId(Inetger id){ Product pr=entityManger.get(1);//it will return ProductObject Set cuts=pr.getCustomers();// it will return set of Customers for(Customers c : cuts){ Sop(c.getProductName());// here we will getException saying that "Exception in thread “main” org.hibernate.LazyInitializationException: " } } Exception: why bcoz after execution of get() method Session object will be closed so proxy Object will be deleted from the Session so that we will get this kind of exception … how can i resolve this problem please help me
- sai
Please mention where to add dialect for hibernate … I wonder how your application is working without specifying dialect…
- Hassan
Followed your spring.xml config but I get this error: org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘entityManagerFactory’: Failed to introspect bean class [org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean] for lookup method metadata: could not find class that it depends on; nested exception is java.lang.NoClassDefFoundError: javax/persistence/SharedCacheMode maybe it’s because of this line here where I get an error ref=“entityManagerFactory” is red and the error : or delimiter expected, got ‘entityManagerFactory’
- yggdras
If you encounter the below issue, No bean named ‘transactionManager’ is defined simply add the bean value next to transaction annotation @Transactional(value = “transactionManager”) public void add(Product product) { productDao.persist(product); } You can also declare the @Transactional annotation at class leve
- Uday