Here is a simple example of how to do a native database query with Hibernate
@Service(Sensor)
abstract class SensorService implements ISensorService {
SessionFactory sessionFactory
Sensor findByTag(String tag){
Session session = sessionFactory.currentSession
String sql = """
"select * from sensor where tag = :tag
"""
Query query = session.createNativeQuery(sql, Sensor)
query.setParameter("tag", tag)
return query.getSingleResult()
}
}