Dear Ryan,
I tried it and it worked like magic. PostgreSQL does have the same function. There were minor problems with your code, this is what I ended up with:
Code:
<class name="org.myclub.hibernate.ClubInfo" table="clubs" lazy="false">
<id name="code">
<generator class="assigned"/>
</id>
<property name="paddedCode"
formula="rpad(code,6)"
insert="false"
update="false"/>
<bag name="regSessions" table="regularsessions" lazy="false">
<key column="club" property-ref="paddedCode"/>
<composite-element class="org.myclub.hibernate.PlaySession">
<property name="day"/>
<property name="time"/>
<property name="info"/>
</composite-element>
</bag>
The only difference is I had to use "code" rather than "club" column in the rpad invocation, and I dropped the third parameter to rpad. I added accessor getPaddedCode() to org.myclub.hibernate.ClubInfo class and that was all.
Before I got your reply, I was reading on Hibernate's facility to extend the set of types, to add my own custom type, but your solution is far simpler.
Thank you very,very much