org.hibernate.AnnotationException: Unknown Id.generator

Problem Runing the following Hibernate’s annotation sequence generator with PostgreSQL database. @Id @Column(name="user_id", nullable=false) @GeneratedValue(strategy = GenerationType.SEQUENCE ,generator="account_user_id_seq") private Integer userId; Hits the following Unknown Id.generator exception. Caused by: org.hibernate.AnnotationException: Unknown Id.generator: account_user_id_seq at org.hibernate.cfg.BinderHelper.makeIdGenerator(BinderHelper.java:413) at org.hibernate.cfg.AnnotationBinder.bindId(AnnotationBinder.java:1795) at org.hibernate.cfg.AnnotationBinder.processElementAnnotations(AnnotationBinder.java:1229) at org.hibernate.cfg.AnnotationBinder.bindClass(AnnotationBinder.java:733) The sequence “account_user_id_seq” is created in PostgreSQL database, what caused the above exception? Solution …

Read more

How to display hibernate sql parameter values – P6Spy

Question There are many developers asking about Hibernate SQL parameter value question. How to display the Hibernate SQL parameter values that passed to database? Hibernate just display all parameter values as question mark (?). With show_sql property, Hibernate will shows all generated SQL statements, but not the SQL parameter values. For example Hibernate: insert into …

Read more

Remember that ordinal parameters are 1-based! – HibernateTemplate

Problem HibernateTemplate code … getHibernateTemplate().find("from Domain d where d.domainName = :domainName", domainName); When i execute the above code, i hit the following error message java.lang.IndexOutOfBoundsException: Remember that ordinal parameters are 1-based! … at org.hibernate.impl.AbstractQueryImpl.determineType(AbstractQueryImpl.java:397) at org.hibernate.impl.AbstractQueryImpl.setParameter(AbstractQueryImpl.java:369) Solution I go inside and study HibernateTemplate.java file and find below code public List find(final String queryString, final Object[] …

Read more

Why i choose Hibernate for my project?

Currently my company is using IBATIS and pure SQLs as database persistence mechanism. I like SQL query very much, especially in tuning, but i do not like to write all SQL statement in Java application, it’s easy to hit typo error and what a stupid and tedious job? Finally my company has a new project …

Read more