Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there something similar to Nhibernate "Mapping by code" for Hibernate

In Nhibernate we have Fluent Nhibernate and, now, the built-in "Mapping by code" feature in Nhibernate 3.2. Both allow you to programmatically construct the mappings for your Domain and we could either write some conventions to map all the domain or we could write individual classes for each corresponding domain object.

Anything similar for Hibernate?

like image 847
Newbie Avatar asked Apr 01 '12 23:04

Newbie


1 Answers

You should be able to configure Hibernate without XML and Annotations by using the Hibernate Configuration API, see http://docs.jboss.org/hibernate/orm/4.1/javadocs/org/hibernate/cfg/Configuration.html

Table mappings can be created through the Mappings API: http://docs.jboss.org/hibernate/orm/4.1/javadocs/org/hibernate/cfg/Mappings.html

I've never used the latter one as I found annotations the best way to go - but maybe the pointer helps.

like image 76
PepperBob Avatar answered Nov 04 '22 22:11

PepperBob