This week's book giveaway is in the Agile and Other Processes forum.
We're giving away four copies of The Little Book of Impediments (e-book only) and have Tom Perry on-line!
See this thread for details.
Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to write mapping for Map

 
amjad sharif
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have the following scenarios for which i need to write hibernate mapping file.


My POJO has the folllowing structure,

public class Test implemets Serializable {

public Test() {
}

private Map<String, Set<String>> variable1;

public void setVariable1(final Map<String, Set<String>> theVariable1) {
variable1 = theVariable1;
}


public Map<String, Set<String>> getVariable1() {
return variable1;
}

private Map<String, Map<String>> variable2;

public void setVariable2(final Map<String, Map<String>> theVariable2) {
variable1 = theVariable2;
}


public Map<String, Set<String>> getVariable2() {
return variable2;
}

}

This object structure is a valid one, as i can implement this object model with out using hibernate. "If something i can do with out using hibernate, i should be able to do that using hibernate too".

I hope everybody accept this statment. Now the problem is i dont know the answer to the following question,

How do i write the hibernate mapping for both these variables, variable1 and variable2 in the Test.hbm.xml file?

Please help me out ASAP.

Thanks,
Amjath Sharief
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hibernate3 does support generics, so you can use them to define associations. Can you explain the association you are trying to implement? You seem to have a Map of Sets, and I can't think of a relationship you could define between two tables in a relational database which would need this association. Could you describe the table structure you are trying to map?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic