java - Need help getting Spring, Hibernate project working again with Hibernate reverse engineering creates classes -
i had project working few months firm moving new model classes need help getting spring, hibernate project working 1 time again hibernate reverse engineering science created.
below dao code worked in past
@transactional(readonly=true, propagation=propagation.required) public memberinquirylookup getmemberinquirylookup(string requester) {
log.debug("looking info for:" + requester); memberinquirylookup dr = (memberinquirylookup) sessionfactory.getcurrentsession() .get(memberinquirylookup.class, requester); if (dr == null) { log.debug("no info :" + requester + " found."); dr = new memberinquirylookup(); } homecoming dr; }
and here old model class:
@entity @table(name = " member_inquiry_lookup") public class memberinquiryinformation { @id @column(name = "email") private string email; @column(name = "first_name") private string first_name; @column(name = "last_name") private string last_name; public string getfirst_name() { homecoming first_name; } public void setfirst_name(string first_name) { first_name = first_name; } public string getlast_name() { homecoming last_name; } public void setlast_name(string last_name) { last_name = last_name; } @column(name = "member_id") private string member_id; @column(name = "school_id") private string school_id; @column(name = "title_id") private string title_id; @column(name = "title_description") private string title_description; @column(name = "school_search_name") private string school_search_name; @column(name = "borough_description") private string borough_description; @column(name = "district") private string district; @column(name = "phone") private string phone; @column(name = "file_number") private string file_number; @column(name = "member_group") private string member_group; public string getemail() { homecoming email; } public void setemail(string email) { this.email = email; } public string getmember_id() { homecoming member_id; } public void setmember_id(string member_id) { this.member_id = member_id; } public string getschool_id() { homecoming school_id; } public void setschool_id(string school_id) { this.school_id = school_id; } public string gettitle_id() { homecoming title_id; } public void settitle_id(string title_id) { this.title_id = title_id; } public string gettitle_description() { homecoming title_description; } public void settitle_description(string title_description) { this.title_description = title_description; } public string getschool_search_name() { homecoming school_search_name; } public void setschool_search_name(string school_search_name) { this.school_search_name = school_search_name; } public string getborough_description() { homecoming borough_description; } public void setborough_description(string borough_description) { this.borough_description = borough_description; } public string getdistrict() { homecoming district; } public void setdistrict(string district) { this.district = district; } public string getphone() { homecoming phone; } public void setphone(string phone) { this.phone = phone; } public string getfile_number() { homecoming file_number; } public void setfile_number(string file_number) { this.file_number = file_number; } public string getmember_group() { homecoming member_group; } /** * @return */ public string getqueue() { if (getmember_group().equalsignorecase("rt")) homecoming "retiree"; homecoming getborough_description(); /*if (getborough_description().equalsignorecase("bronx")) homecoming constants.bronx; if (getborough_description().equalsignorecase("brooklyn")) homecoming constants.brooklyn; if (getborough_description().equalsignorecase("queens")) homecoming constants.queens; if (getborough_description().equalsignorecase("manhattan")) homecoming constants.manattan; if (getborough_description().equalsignorecase("staten island")) homecoming constants.statenisland;*/ } public void setmember_group(string member_group) { this.member_group = member_group; } }
but hibernate reverse engineering science creates next 2 classed same table:
@entity @table(name = "member_inquiry_lookup") public class memberinquirylookup implements java.io.serializable { private memberinquirylookupid id; public memberinquirylookup() { } public memberinquirylookup(memberinquirylookupid id) { this.id = id; } @embeddedid @attributeoverrides({ @attributeoverride(name = "email", column = @column(name = "email", nullable = false)), @attributeoverride(name = "memberid", column = @column(name = "member_id")), @attributeoverride(name = "firstname", column = @column(name = "first_name", length = 15)), @attributeoverride(name = "lastname", column = @column(name = "last_name", length = 25)), @attributeoverride(name = "schoolid", column = @column(name = "school_id", length = 10)), @attributeoverride(name = "titleid", column = @column(name = "title_id", length = 5)), @attributeoverride(name = "titledescription", column = @column(name = "title_description", length = 60)), @attributeoverride(name = "schoolsearchname", column = @column(name = "school_search_name")), @attributeoverride(name = "boroughdescription", column = @column(name = "borough_description")), @attributeoverride(name = "district", column = @column(name = "district")), @attributeoverride(name = "phone", column = @column(name = "phone", length = 16)), @attributeoverride(name = "filenumber", column = @column(name = "file_number", length = 9)), @attributeoverride(name = "membergroup", column = @column(name = "member_group", length = 4)) }) public memberinquirylookupid getid() { homecoming this.id; } public void setid(memberinquirylookupid id) { this.id = id; } }
and
@embeddable public class memberinquirylookupid implements java.io.serializable { private string email; private integer memberid; private string firstname; private string lastname; private string schoolid; private string titleid; private string titledescription; private string schoolsearchname; private string boroughdescription; private string district; private string phone; private string filenumber; private string membergroup; public memberinquirylookupid() { } public memberinquirylookupid(string email) { this.email = email; } public memberinquirylookupid(string email, integer memberid, string firstname, string lastname, string schoolid, string titleid, string titledescription, string schoolsearchname, string boroughdescription, string district, string phone, string filenumber, string membergroup) { this.email = email; this.memberid = memberid; this.firstname = firstname; this.lastname = lastname; this.schoolid = schoolid; this.titleid = titleid; this.titledescription = titledescription; this.schoolsearchname = schoolsearchname; this.boroughdescription = boroughdescription; this.district = district; this.phone = phone; this.filenumber = filenumber; this.membergroup = membergroup; } @column(name = "email", nullable = false) public string getemail() { homecoming this.email; } public void setemail(string email) { this.email = email; } @column(name = "member_id") public integer getmemberid() { homecoming this.memberid; } public void setmemberid(integer memberid) { this.memberid = memberid; } @column(name = "first_name", length = 15) public string getfirstname() { homecoming this.firstname; } public void setfirstname(string firstname) { this.firstname = firstname; } @column(name = "last_name", length = 25) public string getlastname() { homecoming this.lastname; } public void setlastname(string lastname) { this.lastname = lastname; } @column(name = "school_id", length = 10) public string getschoolid() { homecoming this.schoolid; } public void setschoolid(string schoolid) { this.schoolid = schoolid; } @column(name = "title_id", length = 5) public string gettitleid() { homecoming this.titleid; } public void settitleid(string titleid) { this.titleid = titleid; } @column(name = "title_description", length = 60) public string gettitledescription() { homecoming this.titledescription; } public void settitledescription(string titledescription) { this.titledescription = titledescription; } @column(name = "school_search_name") public string getschoolsearchname() { homecoming this.schoolsearchname; } public void setschoolsearchname(string schoolsearchname) { this.schoolsearchname = schoolsearchname; } @column(name = "borough_description") public string getboroughdescription() { homecoming this.boroughdescription; } public void setboroughdescription(string boroughdescription) { this.boroughdescription = boroughdescription; } @column(name = "district") public string getdistrict() { homecoming this.district; } public void setdistrict(string district) { this.district = district; } @column(name = "phone", length = 16) public string getphone() { homecoming this.phone; } public void setphone(string phone) { this.phone = phone; } @column(name = "file_number", length = 9) public string getfilenumber() { homecoming this.filenumber; } public void setfilenumber(string filenumber) { this.filenumber = filenumber; } @column(name = "member_group", length = 4) public string getmembergroup() { homecoming this.membergroup; } public void setmembergroup(string membergroup) { this.membergroup = membergroup; } public boolean equals(object other) { if ((this == other)) homecoming true; if ((other == null)) homecoming false; if (!(other instanceof memberinquirylookupid)) homecoming false; memberinquirylookupid castother = (memberinquirylookupid) other; homecoming ((this.getemail() == castother.getemail()) || (this.getemail() != null && castother.getemail() != null && this.getemail().equals( castother.getemail()))) && ((this.getmemberid() == castother.getmemberid()) || (this .getmemberid() != null && castother.getmemberid() != null && .getmemberid().equals(castother.getmemberid()))) && ((this.getfirstname() == castother.getfirstname()) || (this .getfirstname() != null && castother.getfirstname() != null && .getfirstname().equals(castother.getfirstname()))) && ((this.getlastname() == castother.getlastname()) || (this .getlastname() != null && castother.getlastname() != null && .getlastname().equals(castother.getlastname()))) && ((this.getschoolid() == castother.getschoolid()) || (this .getschoolid() != null && castother.getschoolid() != null && .getschoolid().equals(castother.getschoolid()))) && ((this.gettitleid() == castother.gettitleid()) || (this .gettitleid() != null && castother.gettitleid() != null && .gettitleid().equals(castother.gettitleid()))) && ((this.gettitledescription() == castother .gettitledescription()) || (this.gettitledescription() != null && castother.gettitledescription() != null && .gettitledescription().equals( castother.gettitledescription()))) && ((this.getschoolsearchname() == castother .getschoolsearchname()) || (this.getschoolsearchname() != null && castother.getschoolsearchname() != null && .getschoolsearchname().equals( castother.getschoolsearchname()))) && ((this.getboroughdescription() == castother .getboroughdescription()) || (this .getboroughdescription() != null && castother.getboroughdescription() != null && .getboroughdescription().equals( castother.getboroughdescription()))) && ((this.getdistrict() == castother.getdistrict()) || (this .getdistrict() != null && castother.getdistrict() != null && .getdistrict().equals(castother.getdistrict()))) && ((this.getphone() == castother.getphone()) || (this .getphone() != null && castother.getphone() != null && .getphone().equals(castother.getphone()))) && ((this.getfilenumber() == castother.getfilenumber()) || (this .getfilenumber() != null && castother.getfilenumber() != null && .getfilenumber().equals(castother.getfilenumber()))) && ((this.getmembergroup() == castother.getmembergroup()) || (this .getmembergroup() != null && castother.getmembergroup() != null && .getmembergroup().equals(castother.getmembergroup()))); } public int hashcode() { int result = 17; result = 37 * result + (getemail() == null ? 0 : this.getemail().hashcode()); result = 37 * result + (getmemberid() == null ? 0 : this.getmemberid().hashcode()); result = 37 * result + (getfirstname() == null ? 0 : this.getfirstname().hashcode()); result = 37 * result + (getlastname() == null ? 0 : this.getlastname().hashcode()); result = 37 * result + (getschoolid() == null ? 0 : this.getschoolid().hashcode()); result = 37 * result + (gettitleid() == null ? 0 : this.gettitleid().hashcode()); result = 37 * result + (gettitledescription() == null ? 0 : .gettitledescription().hashcode()); result = 37 * result + (getschoolsearchname() == null ? 0 : .getschoolsearchname().hashcode()); result = 37 * result + (getboroughdescription() == null ? 0 : .getboroughdescription().hashcode()); result = 37 * result + (getdistrict() == null ? 0 : this.getdistrict().hashcode()); result = 37 * result + (getphone() == null ? 0 : this.getphone().hashcode()); result = 37 * result + (getfilenumber() == null ? 0 : this.getfilenumber() .hashcode()); result = 37 * result + (getmembergroup() == null ? 0 : this.getmembergroup() .hashcode()); homecoming result; } }
so mvn bundle , getting next error:
tests in error: testgetmemeberrequestinformation(org.uftwf.memberinquiry.test.testapp): provided id of wrong type class org.uftwf.model.memberinquirylookup. expected: class org.uftwf.model.memberinquirylookupid, got class java.lang.string
you're doing lookup through hibernate requester, assume string. id in entity memberinquirylookupid. hibernate not know on column should match given value.
a workaround work criteria api or write hql:
from memberinquirylookup m m.id.email = :parameter
it seems me hibernate reverse engineered table in wrong manner. have composite primary key in database? if not, should adapt code right error.
java mysql spring hibernate
No comments:
Post a Comment