Code:
@Entity
@Table(name = "CONTACTS")
@SQLInsert(sql="INSERT INTO CONTACT(FIRST_NAME, LAST_NAME) VALUES(upper('aaa'),upper('bbb'))")
public class Contact {
// ...
}
I've tried the both - sql-query and stored procedure inside the @SQLInsert. But the both not work for me. It looks like the @SQLInsert annotation is just ignored for some reason. Usual "insert into CONTACT (FIRST_NAME, LAST_NAME) values (?, ?)" statement is generated despite of the @SQLInsert annotation. At the same time other annotations (@NamedNativeQuery, @Loader) work ok for the class.
How to make it works, please?
Thanks a lot in advance.
Hibernate version: hibernate-3.2.3.ga.zip
Mapping documents:Code:
sessionFactory = new AnnotationConfiguration()
.addPackage("model")
.addAnnotatedClass(Contact.class)
.addAnnotatedClass(SpaceShip.class)
.setProperty("hibernate.dialect", "org.hibernate.dialect.MySQLMyISAMDialect")
.setProperty("hibernate.connection.url", "jdbc:mysql://localhost/test")
.setProperty("hibernate.connection.driver_class", "com.mysql.jdbc.Driver")
.setProperty("hibernate.connection.username", "usname")
.setProperty("hibernate.connection.password", "1231123")
.setProperty(Environment.HBM2DDL_AUTO, "update")
.setProperty(Environment.SHOW_SQL, "true")
.setProperty("hibernate.cache.provider_class", "org.hibernate.cache.NoCacheProvider")
.buildSessionFactory();
Code between sessionFactory.openSession() and session.close():Code:
session = HibernateUtil.getSession();
session.beginTransaction();
session.saveOrUpdate(newContact);
session.getTransaction().commit();
Full stack trace of any exception that occurs:
None
Name and version of the database you are using:
MySQL client version: 5.0.22
The generated SQL (show_sql=true):
Hibernate: insert into CONTACT (FIRST_NAME, LAST_NAME) values (?, ?)