Is there a way to create OrderedMapType in Hibernate. I was looking through the sample test-cases but couldn't found one creating OrderedMapType in Hibernate.
My Sample Mapping file is as shown below:
Code:
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class entity-name="ccategories" lazy="true" table="Categories">
<tuplizer class="org.hibernate.bugs.SampleTuplizer" entity-mode="dynamic-map"/>
<id name="CategoryID" type="int">
<column length="10" name="CategoryID"/>
</id>
<property name="CategoryName" type="string">
<column name="CategoryName" not-null="true"/>
</property>
<property name="Description" type="string">
<column name="Description"/>
</property>
<property name="Picture" type="binary">
<column name="Picture"/>
</property>
<bag name="bagproducts" table="products">
<key column="CategoryID"/>
<element column="productname" type="string"/>
</bag>
<map name="mapProducts" table="products">
<key column="CategoryID"/>
<map-key column="ProductID" type="int"/>
<element column="productname" type="string"/>
</map>
<bag name="bagProductsOrdered" order-by="ProductName" table="products">
<key column="CategoryID"/>
<element column="productname" type="string"/>
</bag>
<map name="mapProductsOrdered" order-by="ProductID" table="products">
<key column="CategoryID"/>
<map-key column="ProductID" type="int"/>
<element column="productname" type="string"/>
</map>
</class>
</hibernate-mapping>
In Hibernate 4.3 this used to get initialized through this piece of code
https://github.com/hibernate/hibernate-orm/blob/4.3/hibernate-core/src/main/java/org/hibernate/cfg/HbmBinder.java#L1413 but after the new Metamodel API initialization it checks it here
https://github.com/hibernate/hibernate-orm/blob/master/hibernate-core/src/main/java/org/hibernate/boot/model/source/internal/hbm/ModelBinder.java#L1362 which in turn invokes the following method call
https://github.com/hibernate/hibernate-orm/blob/master/hibernate-core/src/main/java/org/hibernate/boot/model/source/internal/hbm/ModelBinder.java#L1566This can't be true as
PluralAttributeSourceMapImpl doesn't implements
Orderable.
I was checking the source-code of Hibernate and could easily find out a way to create OrderedMap Type here
https://github.com/hibernate/hibernate-orm/blob/master/hibernate-core/src/main/java/org/hibernate/type/TypeFactory.java#L331 but couldn't find a sample example as to how it can be invoked from the code.
Can some-one please share the details regarding this.