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

Emmanuel Bernard (JIRA) noreply at atlassian.com
Thu Oct 18 17:42:38 EDT 2007


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

Emmanuel Bernard commented on ANN-666:
--------------------------------------

Can you try Hibernate Annotations 3.3.0
Because I have a test just for that, very much like yours
o.h.t.a.query.QueryAndSQLTest.testEntitySQLOverriding 
and it passes :)

> @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