Reputation: 57
For Example:
login user is [test2] and I want to update mAccount
and mPassword
.
How to get login session and click on the jsp form to update?
(mId
is Primary Key)
What should I do?
When I click submit to update the SQL database, mAccount
and mPassword
are not updated.
I think my controller must have problem to get login session, so I can't update what I want. I click again and again but SQL database still not any change,controller not get test2 object to update.how to fix controller let me so confuse and anxious.this problem spent me 1week ...
SQL Member
database:
Edit: Was same image as above, likely missing the intended one
UpdateMemberController
debug mode:
Bean:
private Integer mId;
private String mAccount;
private String mPassword;
private String mName;
private Date mDate;
private String mPhone;
private String mAddress;
private String mGender;
private String mEmail;
MemberDao:
public void setConnection(Connection conn);
public boolean checkAccount(String mAccount);
public int registerMember(MemberBean mb);
public MemberBean queryMember(String mAccount);
public MemberBean checkPassword(String mAccount, String mPassword);
public void updateMember(MemberBean mb);
DaoImpl:
@Override
public void updateMember(MemberBean mb) {
String hql = "UPDATE MemberBean mb SET mb.mAccount =:mAccount , mb.mPassword =:mPassword WHERE mId =:mId";
Session session = factory.getCurrentSession();
session.createQuery(hql).setParameter("mAccount", mb.getmAccount()).setParameter("mPassword", mb.getmPassword())
.setParameter("mId", mb.getmId()).executeUpdate();
}
MemberService:
boolean accountCheck(String mAccount);
int registerMember(MemberBean mb);
MemberBean queryMember(String mAccount);
public MemberBean checkPassword(String mAccount, String mPassword);
void updateMember(MemberBean mb );
MemberSeriveImpl:
@Transactional
@Override
public void updateMember(MemberBean mb) {
if (mb.getmAccount() != null && mb.getmPassword() != null) {
dao.updateMember(mb);
}
}
Upvotes: 4
Views: 116
Reputation: 3543
There is nothing bigger challenge for a developer if he get hold on debugging skills. If anything causing problem to developer he should hold the neck of that and solve it.
Check hibernate.properties for which database you have connected. If you connected to different database, update may be happening there. (If step1 has no problem)
Directly jump to debug your dao implementation.(updateMember() method)
Step 3: Why it is not updating to database. Am i committing transactions?
If i am relied on spring to manage transactions (begin, commit/rollback) then question yourself am i configured it correctly?
(Even i have not worked on Transaction in spring let me guess your problem)
Is spring container picking up service method with @Transactional?
What is your component scan base package? what is the package name of your service?
Is your service class scanned for components?
Note:
Add necessary information in your question
Add servlet-context.xml(in xml configuration) or equivalent java configuration file
Add root-context.xml (in xml configuration) or equivalent java configuration file
Filter question or remove unnecessary information
Bean(required)
MemberDao(required)
MemberService(required)
MemberSeriveImpl(required)
controller(Not required)
jsp(not required)
Upvotes: 2