java - How to persist a custom map with Hibernate/JPA? -
I try to continue a subclassified This parameter gives me the following exception when trying to store this parameter: When I announce the I get the following output: If I change it Code> Private map & lt; String, string & gt; Parameters = new Hashmap & lt; & Gt; (); Everything works fine. How can I tell the hibernate as a this is untested Perhaps you can try and see that this work Does: Why Not only a JPA works by using the normal archive interface: : From: In addition, allows lazy loading, ie, because the Hibernate classes Therefore, you originally returned the hibernate archive. Some of this effect: hashmap in the database using hibernate and JPA annotations I am doing
import javax.preistence.CollectionTable; Import javax.preistence.Column; Import javax.preistence.ElementCollection; Import javax.preistence.Entity; Import javax.preistence.FetchType; Import javax.preistence.GeneratedValue; Import javax.preistence.Id; Import javax.preistence.MapKeyColumn; Import javax.preistence.Table; @Entity @Table (name = "module") Public class module {@Id @ generatedValue @Column (name = "id") Private ID ID; @column (name = "name") private string name; @column (name = "description") private string description; @ Column (name = "version") private string version; @ElementCollection (fetch = FetchType.EAGER) @CollectionTable (name = "module_parameter") @MapKeyColumn (name = "key") @column (name = "value") Private parameter parameters = new parameter (); // Gates & amp; Setters}
org.hibernate.AnnotationException: The form of non-archive one Invalid attempt to map to @OneToMany, @ManyToMany, or @CollectionOfElements: Module.params
private map & lt; String, string & gt; Parameters = new parameter (); Public Parameter Received Parameters () {Return Parameters; }
Hibernate: Modul0_. Id choose as id1_0_, as Modul0_diskripshn descript2_0_, module0_.name name3_0_ , As the module0_. Module module version 4_0_ as version: hibernate: parameter0_ In the form of module_ID as module_i1_0_0_, parameter0_.value value2_1_0_, select parameter0_key as key3_0_module_mapmeter Parameters0_ where parameter0_ Module_id =?
parameter collection?
Map & lt; String, string & gt; ?
list ,
set ,
map . Thus, if
parameter is-ace
map , you can return it as the
Map . Change
get public parameter first () {return parameter}; }
Public map & lt; String, string & gt; GetParams () {Return Ultimate; }
Persistent list ,
PersistentSet ,
PersistentMap , etc., you can use the structure to return to a
parameter that comes back from hibernation.
public map & lt; String, string & gt; GetParams () {new parameter back (parameter); // parameter is injected with Hibernate's persistentmap. }
Comments
Post a Comment