0

I'm working on a Spring MVC legacy project and currently, we are upgrading the spring(2) and hibernate(2) to latest version. Previously in the project there are sql-query and entity mappings are done in the XML files and we are upgrading the entity mapping from XML to annotation based. The problem is occurring for the entity mappings that are done on the basis of the result set of a query. I want to keep the query in the XML files only(as these are very very big queries performing joins on 4-5 tables) and just change the entity mapping. Previously the entity mapping is done like this

<class name="ClassName" table="x" mutable="false">
    <id name="id" column="id_col">
        <generator class="assigned" />
    </id>
        <property name="linkId"  ....

</class>

How will I annotate table='x' in the annotation based mapping?

P.S table="x" is not an example it is written in that way only in XML mapping and there is no table named x in DB

Sanchit Patiyal
  • 4,910
  • 1
  • 14
  • 31

1 Answers1

-1

you can use like this

@Entity
@Table(name = "X")
public class ClassName {
}

In native Query in xml

<sql-query name="findQuery">
   <return alias="ClassName" class="ClassName"/>
   select * from x
</sql-query>
Chamly Idunil
  • 1,848
  • 1
  • 18
  • 33