spring - Adding parameters with @Query annotation -


i'm unable add parameters spring jpa @query annotation. i've tried 2 ways , both parameter position [1] did not exist , syntax error @ or near "$1"

@transactional     @modifying     @query(value="alter table :table add constraint someconstraint", nativequery=true)     void addconstraint(@param("table") string table);     @transactional     @modifying     @query(value="alter table ?1 add constraint someconstraint", nativequery=true)     void addconstraint(string table); 

spring data jpa doesn't support ddl queries @query annotation.

with jpa 2.1 can add @index annotation entity class , index gets created seamlessly:

import javax.persistence.column; import javax.persistence.entity; import javax.persistence.index; import javax.persistence.table;  @entity @table(name = "mytable",         indexes = {                 @index(name = "my_table_idx_1", columnlist = "native_col_name")         } ) public class myentity {      @column(name = "native_col_name")     private string myattribute;      public string getmyattribute() {         return myattribute;     }      public void setmyattribute(final string myattribute) {         this.myattribute = myattribute;     } } 

}


Comments

Popular posts from this blog

1111. appearing after print sequence - php -

java - WARN : org.springframework.web.servlet.PageNotFound - No mapping found for HTTP request with URI [/board/] in DispatcherServlet with name 'appServlet' -

Ruby on Rails, ActiveRecord, Postgres, UTF-8 and ASCII-8BIT encodings -