java - Persisting time ojects as entities instead of value types? -
i'm using joda time datetime handle date , time. persist objects of kind using class persistentdatetime bundled in jodatime hibernate code.
i have large collections of datetime objects, , persist them in following way (an excerpt of hibernate mapping file follows):
<set name="validinstants" sort="natural"> <key column="myobject_id"/> <element column="date" type="myproject.utilities.hibernate.types.persistentdatetime"/> </set>
doing so, i.e. storing datetimes value types, many duplicate elements in table validinstants, hundreds of thousands of them. i'd avoid , have in validinstants table datetimes needed, stored once per value. how can achieve this?
as far know (i'm , hibernate beginner) way achieve creating class wraps datetime , maps entity, plus creating factory returns same datetime-wrapper when asking same date. best way want? suggestions?
what relationship between entity being stored here , validinstants
set? entity "own" validinstants? member of validinstants
have use or life outside of entity declared part of?
if not, don't think makes sense treat non-entity entity (which you'd doing if "creating class wraps datetime , maps entity").
i not worry having many duplicate elements in table storing these dates, unless it's proven large problem. indexing on myobject_id
column, these lookups should fast enough.
Comments
Post a Comment