Friday, February 29, 2008

Metawidget and Hibernate

Metawidget's new HibernateInspector knows how to inspect hibernate.cfg.xml files such as:

<hibernate-configuration>
  <session-factory>
    ...
    <mapping resource="mapping1.hbm.xml"/>
    <mapping resource="mapping2.hbm.xml"/>
    <mapping resource="mapping3.hbm.xml"/>
  </session-factory>
</hibernate-configuration>

From there, it traverses into the multiple mapping files such as...

<hibernate-mapping package="org.foo">
  <class name="Foo">
    <id name="baz"/>
    <property name="abc" type="clob"/>
  </class>
</hibernate-mapping>

...to extract useful UI hints. Hints like:
  • not-null fields are required fields
  • clob fields are large text boxes (like HTML textareas)
  • length attributes constrain input length
  • ids are hidden (though this is configurable)

These are the same features JpaInspector looks for in JPA annotations.

0 comments: