-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Need help getting Spring, Hibernate project working again
PostPosted: Wed Feb 06, 2013 12:28 pm 
Newbie

Joined: Mon Feb 04, 2013 2:28 pm
Posts: 4
I had my project working for a few months now but my firm is moving to new model classes that are Need help getting Spring, Hibernate project working again with Hibernate reverse engineering created.

Below is my DAO code that worked in the past



@Transactional(readOnly=true, propagation=Propagation.REQUIRED)
public MemberInquiryLookup getMemberInquiryLookup(String requester) {


log.debug("Looking for data for:" + requester);


MemberInquiryLookup dr = (MemberInquiryLookup)
sessionFactory.getCurrentSession()
.get(MemberInquiryLookup.class, requester);
if (dr == null) {
log.debug("NO DATA for :" + requester + " was found.");

dr = new MemberInquiryLookup();
}
return dr;

}

and here is my 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() {
return First_Name;
}

public void setFirst_Name(String first_Name) {
First_Name = first_Name;
}

public String getLast_Name() {
return 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() {
return email;
}

public void setEmail(String email) {
this.email = email;
}

public String getMember_id() {
return member_id;
}

public void setMember_id(String member_id) {
this.member_id = member_id;
}

public String getSchool_id() {
return school_id;
}

public void setSchool_id(String school_id) {
this.school_id = school_id;
}

public String getTitle_id() {
return title_id;
}

public void setTitle_id(String title_id) {
this.title_id = title_id;
}

public String getTitle_description() {
return title_description;
}

public void setTitle_description(String title_description) {
this.title_description = title_description;
}

public String getSchool_search_name() {
return school_search_name;
}

public void setSchool_search_name(String school_search_name) {
this.school_search_name = school_search_name;
}

public String getBorough_description() {
return borough_description;
}

public void setBorough_description(String borough_description) {
this.borough_description = borough_description;
}

public String getDistrict() {
return district;
}

public void setDistrict(String district) {
this.district = district;
}

public String getPhone() {
return phone;
}

public void setPhone(String phone) {
this.phone = phone;
}

public String getFile_number() {
return file_number;
}

public void setFile_number(String file_number) {
this.file_number = file_number;
}

public String getMember_group() {
return member_group;
}

/**
* @return
*/
public String getQueue() {
if (getMember_group().equalsIgnoreCase("RT"))
return "Retiree";

return getBorough_description();

/*if (getBorough_description().equalsIgnoreCase("BRONX"))
return Constants.BRONX;

if (getBorough_description().equalsIgnoreCase("BROOKLYN"))
return Constants.BROOKLYN;

if (getBorough_description().equalsIgnoreCase("QUEENS"))
return Constants.QUEENS;

if (getBorough_description().equalsIgnoreCase("MANHATTAN"))
return Constants.MANATTAN;

if (getBorough_description().equalsIgnoreCase("STATEN ISLAND"))
return Constants.STATENISLAND;*/

}

public void setMember_group(String member_group) {
this.member_group = member_group;
}

}

but Hibernate reverse engineering creates the following TWO classed for the 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() {
return 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() {
return this.email;
}

public void setEmail(String email) {
this.email = email;
}

@Column(name = "member_id")
public Integer getMemberId() {
return this.memberId;
}

public void setMemberId(Integer memberId) {
this.memberId = memberId;
}

@Column(name = "first_name", length = 15)
public String getFirstName() {
return this.firstName;
}

public void setFirstName(String firstName) {
this.firstName = firstName;
}

@Column(name = "last_name", length = 25)
public String getLastName() {
return this.lastName;
}

public void setLastName(String lastName) {
this.lastName = lastName;
}

@Column(name = "school_id", length = 10)
public String getSchoolId() {
return this.schoolId;
}

public void setSchoolId(String schoolId) {
this.schoolId = schoolId;
}

@Column(name = "title_id", length = 5)
public String getTitleId() {
return this.titleId;
}

public void setTitleId(String titleId) {
this.titleId = titleId;
}

@Column(name = "title_description", length = 60)
public String getTitleDescription() {
return this.titleDescription;
}

public void setTitleDescription(String titleDescription) {
this.titleDescription = titleDescription;
}

@Column(name = "school_search_name")
public String getSchoolSearchName() {
return this.schoolSearchName;
}

public void setSchoolSearchName(String schoolSearchName) {
this.schoolSearchName = schoolSearchName;
}

@Column(name = "borough_description")
public String getBoroughDescription() {
return this.boroughDescription;
}

public void setBoroughDescription(String boroughDescription) {
this.boroughDescription = boroughDescription;
}

@Column(name = "district")
public String getDistrict() {
return this.district;
}

public void setDistrict(String district) {
this.district = district;
}

@Column(name = "phone", length = 16)
public String getPhone() {
return this.phone;
}

public void setPhone(String phone) {
this.phone = phone;
}

@Column(name = "file_number", length = 9)
public String getFileNumber() {
return this.fileNumber;
}

public void setFileNumber(String fileNumber) {
this.fileNumber = fileNumber;
}

@Column(name = "member_group", length = 4)
public String getMemberGroup() {
return this.memberGroup;
}

public void setMemberGroup(String memberGroup) {
this.memberGroup = memberGroup;
}

public boolean equals(Object other) {
if ((this == other))
return true;
if ((other == null))
return false;
if (!(other instanceof MemberInquiryLookupId))
return false;
MemberInquiryLookupId castOther = (MemberInquiryLookupId) other;

return ((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 && this
.getMemberId().equals(castOther.getMemberId())))
&& ((this.getFirstName() == castOther.getFirstName()) || (this
.getFirstName() != null
&& castOther.getFirstName() != null && this
.getFirstName().equals(castOther.getFirstName())))
&& ((this.getLastName() == castOther.getLastName()) || (this
.getLastName() != null
&& castOther.getLastName() != null && this
.getLastName().equals(castOther.getLastName())))
&& ((this.getSchoolId() == castOther.getSchoolId()) || (this
.getSchoolId() != null
&& castOther.getSchoolId() != null && this
.getSchoolId().equals(castOther.getSchoolId())))
&& ((this.getTitleId() == castOther.getTitleId()) || (this
.getTitleId() != null && castOther.getTitleId() != null && this
.getTitleId().equals(castOther.getTitleId())))
&& ((this.getTitleDescription() == castOther
.getTitleDescription()) || (this.getTitleDescription() != null
&& castOther.getTitleDescription() != null && this
.getTitleDescription().equals(
castOther.getTitleDescription())))
&& ((this.getSchoolSearchName() == castOther
.getSchoolSearchName()) || (this.getSchoolSearchName() != null
&& castOther.getSchoolSearchName() != null && this
.getSchoolSearchName().equals(
castOther.getSchoolSearchName())))
&& ((this.getBoroughDescription() == castOther
.getBoroughDescription()) || (this
.getBoroughDescription() != null
&& castOther.getBoroughDescription() != null && this
.getBoroughDescription().equals(
castOther.getBoroughDescription())))
&& ((this.getDistrict() == castOther.getDistrict()) || (this
.getDistrict() != null
&& castOther.getDistrict() != null && this
.getDistrict().equals(castOther.getDistrict())))
&& ((this.getPhone() == castOther.getPhone()) || (this
.getPhone() != null && castOther.getPhone() != null && this
.getPhone().equals(castOther.getPhone())))
&& ((this.getFileNumber() == castOther.getFileNumber()) || (this
.getFileNumber() != null
&& castOther.getFileNumber() != null && this
.getFileNumber().equals(castOther.getFileNumber())))
&& ((this.getMemberGroup() == castOther.getMemberGroup()) || (this
.getMemberGroup() != null
&& castOther.getMemberGroup() != null && this
.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 : this
.getTitleDescription().hashCode());
result = 37
* result
+ (getSchoolSearchName() == null ? 0 : this
.getSchoolSearchName().hashCode());
result = 37
* result
+ (getBoroughDescription() == null ? 0 : this
.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());
return result;
}

}

so now I do a mvn package and I am getting the following error:

Tests in error:
testgetMemeberRequestInformation(org.uftwf.memberinquiry.test.TestApp): Provided id of the wrong type for class org.uftwf.model.MemberInquiryLookup. Expected: class org.uftwf.model.MemberInquiryLookupId, got class java.lang.String


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.