0
votes

My hibernate-mapping.hbm.xml looks like this:

< ?xml version='1.0' encoding='utf-8'?>

< !DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Configuration DTD//EN" "http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">

< hibernate-mapping>

< sql-query name="addAM">

< ![CDATA[INSERT INTO ARCHIVE_MEMBER (EXT_CUST_ID,CREATED_DATE,MODIFIED_DATE,ARCHIVAL_DATE)values(?,?,?,?)]]>

< /sql-query>

< sql-query name="saveServiceHistory">

< ![CDATA[INSERT INTO MEMBER_SERVICE_RECORD (MEMBER_ID, SERVICE_DATE,SERVICE_MILEAGE, SERVICE_DESC, MODIFIED_DATE) VALUES (?, ?, ?, ?, ?)]]>

< /sql-query>

...// many more such named queries

< /hibernate>

But there is nothing like < class name = "abc" table = "ABC"> in this hibernate file. Also, my classes don't have annotations. How are these getting mapped to specific classes then!

1
Btw, it would be helpful if you could specify which Hibernate version you're using.LppEdd

1 Answers

1
votes

Although you don't mention which Hibernate version you're on, those seems native named SQL queries. In newer Hibernate release you should check out

EntityManager#createNamedQuery

While in legacy releases you should check out the Hibernate

Session#getNamedQuery

As per documentation, mapping an entity is not mandatory.
You can also query by receving an Object[].