Ahoj.
Narazil som na podivny problem. Po uprave entit v existujucom projekte (
zmena modelu
vyziadala pouzivanie composite keys ) sa hibernate snazi ako value
kompozitneho kluca
serializovat objekt do blobu ( co asi neni to co chcem ).
Entity vyzeraju nejak takto:
@Entity
@Inheritance(strategy = InheritanceType.JOINED)
public class Material implements Serializable {
@Id
@GeneratedValue ...
private Long material_id;
...
}
@Entity
public class BundledMaterial implements Serializable {
@EmbeddedId
private BundledMaterialPK id; // pouzivam zlozeny kluc
bundle:material
private Long amount;
...
}
@Embeddable
public class BundledMaterialPK implements Serializable {
@OneToOne(mappedBy = "material_id")
private Material material;
@OneToOne(mappedBy = "bundle_id")
private Bundle bundle;
...
}
@Entity
public class Bundle implements Serializable {
@Id
@GeneratedValue ...
private Long bundle_id;
@OneToMany(mappedBy="id.bundle", cascade=CascadeType.ALL)
private List<BundledMaterial> bundledMaterial = new
ArrayList<BundledMaterial>();
...
}
V principe ide o to, ze mam nejaky zoznam materialu, zoznam bundlov,
kazdy bundle obsahuje
mnozinu materialu, kazdy v roznom mnozstve pre kazdy bundle.
Schemu generuje hibernate, pricom logicky vygeneruje nasledovne tabule:
material ( material_id PK, ... )
bundle ( bundle_id PK, ... )
ale uplne nelogicky vygeneruje tabulku BundledMaterial:
bundledmaterial (
bundle blob (?),
material blob (?),
amount long,
primary key ( bundle, amount )
)
a snazi sa BundledMaterialPK.material a BundledMaterialPK.bundle do to
tych blobov hexaserializovat.
Netusi niekto na co som zabudol, pripadne co som spravil zle?
Diky
--
Dusan