Skip to content
Advertisement

Tag: hibernate

JPA @Column annotation to create comment/description

I was wondering is it possible to create from jpa/hibernate annotation a database column description/comment like this: ALTER TABLE tablename CHANGE status status INT(11) NOT NULL COMMENT ‘sample description/comment’; It will be great functionality, but I cant find anything about this in JPA specification. Maybe I should use @Column(columnDefinition=””) property, but I dont have any clue. Please help Answer I

How Spring @Autowired binds the SessionFactory object even if there is no SessionFactory instance available

I’m using Hibernate and Spring with Java-based configurations. My config file is this one: Working fine. No problem with this, but when I manually try to set the sessionfactory parameter for trasactionManager, like this: The IDE is showing: So, I created a sessionFactory like below and passed to trasactionManager It worked. My question is how spring autowired the sessionFactory object

How to count number of rows using JPA?

I try to count number of rows using JPA.I want to use where clause however I can’t. How can I set where clause forexample where age=”45″. Thanks in advance. Answer Use ParameterExpression. Note: Untested. Reference.

No Dialect mapping for JDBC type: 1111

I’m working on a Spring JPA Application, using MySQL as database. I ensured that all spring-jpa libraries, hibernate and mysql-connector-java is loaded. I’m running a mysql 5 instance. Here is a excerpt of my application.properties file: When executing an integration test, spring startsup properly but fails on creating the hibernate SessionFactory, with the exception: I think my dialects should be

Spring MVC request and response flow explanation

I can’t find correct client request flow in below syntax.Could someone please clarify what is happening here? If possible please specify what are the corresponding spring classes/interfaces used in spring MVC process. Answer Request will be received by DispatcherServlet. DispatcherServlet will take the help of HandlerMapping and get to know the @Controller class name associated with the given request. So

Detached entity passed to persist when save the child data

I’m getting this error when submitting the form: org.hibernate.PersistentObjectException: detached entity passed to persist: com.project.pmet.model.Account; nested exception is javax.persistence.PersistenceException: org.hibernate.PersistentObjectException: detached entity passed to persist: com.project.pmet.model.Account Here are my entities: Account: Team: Here’s a part of the Controller: And the form: What am I doing wrong? Answer Save method accepts only transient objects. What is the transient object you can

MySQL to Hibernate datatype mapping for type “YEAR”

There’s a column in our database which needs to be of type YEAR. What is the corresponding Hibernate mapping for the entity? Tried searching all over, but unable to find the details. I am not sure if I need to use anything from @Temporal or any other specific type. We are using Hibernate ORM v4.1.7. Answer You can write a

Advertisement