mysql - how to process generic list List<MyClass> in java to fetch resultset in particular manner -
i making database driven faqs company have class faq.java variables
1.faquid 2.faqquestion 3.faqanswer 4.companyuserrole
so fetching results databse through dao know.ie have made list<> datatype
private list<faq> fetchfaqs; fetchfaqs = faqservice.fetchrnrfaq(rnruser); now fetchfaqs generic list having datatype specified in faq.java.
now lets getting info database
skeleton :
faquid | faqquestion | faqanswer | companyuserrole
data :
1 | question1 | question2 | super admin 2 | question1 | question2 | grouping admin 3 | question1 | question2 | user
so can see have same question , reply of 3 types of roles i.e super admin, grouping admin , user.
when fetch get
frequntly asked questions
q.1 question 1 a.1 reply 1
q.2 question 2 a.2 reply 2
q.3 question 3 a.3 reply 3
what want fetch
frequently asked question (super admin)
q.1 question 1 a.1 reply 1
frequently asked question (group admin)
q.1 question 1 a.1 reply 1
frequently asked question (user)
q.1 question 1 a.1 reply 1
how can implement this?????????????.
ps. nil hardcoded, database driven
faq.java class
private string faqquestion; private string faqanswer; private string faquid; private string userrolename; and there respective getters , setters
group result according companyuserrole field (in map example) , process results every type.
java mysql generics
No comments:
Post a Comment