[hibernate-issues] [Hibernate-JIRA] Commented: (ANN-666) @SQLInsert does not work

Diego Pires Plentz (JIRA) noreply at atlassian.com
Sat Oct 20 11:58:39 EDT 2007


    [ http://opensource.atlassian.com/projects/hibernate/browse/ANN-666?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_28496 ] 

Diego Pires Plentz commented on ANN-666:
----------------------------------------

Alex, you forgot to add hibernate-commons-annotations.jar to you classpath. It's in hibernate-annotations.zip, into the lib folder.

> @SQLInsert  does not work
> -------------------------
>
>                 Key: ANN-666
>                 URL: http://opensource.atlassian.com/projects/hibernate/browse/ANN-666
>             Project: Hibernate Annotations
>          Issue Type: Bug
>    Affects Versions: 3.2.1
>         Environment: hibernate-3.2.3.ga.zip, MySQL client version: 5.0.22, MSSQL 2005
>            Reporter: Alex
>         Attachments: SQLInsertTest.zip
>
>
> http://forum.hibernate.org/viewtopic.php?p=2367176#2367176
> @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: 
>   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(): 
>          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 (?, ?)

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        



More information about the hibernate-issues mailing list