thanks,
it resolved.
in my pojo, getters of associate objects try some query not just return.
alex
On 11/26/05, Jeff Butler <[EMAIL PROTECTED]> wrote:
Yes - #handleby.id# will turn into getHandleby().getId(). No need to ask this question again.Some comments on your example:1. All your fields are private, and you have public accessors. This could be the problem.2. parameterClass must be a fully qualified class name. You've example shows parameterClass="account" - but I think that "account" is not the fully qualified class name. This could be the problem.If your example is truly as you've posted, it will never work. The first thing I would try is to turn the parameterClass into the correct class name, and add some public getters/setters.Jeff Butler
On 11/26/05, Alex Chew <[EMAIL PROTECTED] > wrote:No,Patelthat is not what i want.I dont like to get handleby user id manually , you know , handleby attribute of Account is type of User, not Long or Integer.i'd like to use my pojo in oo way ,not face to persistent field directly.what i want to know is whether ibatis can work just like OGNL ,and this still is the key point, does #handleby.id# will be auto unwrapped in getHandleby().getId() way.thanks anymore.is cliniton there? show me the way please.
On 11/26/05, Sheshadri Patel < [EMAIL PROTECTED] > wrote:
On 11/26/05, Alex Chew <[EMAIL PROTECTED] > wrote:If this enough?POJO:
public class Account implements Serializable {
private Long id;
private String name;
private Double deposit;
private User handleby; Ur wrong here
}
public class User implements Serializable {
private Long id;
private String username;
private String password;
}
SQL:
<insert id="insertAccount" parameterClass="account">
insert into ACCOUNT (ID,NAME, DEPOSITE, FK_HANDLEBY)
values (#id#, #name#, #deposit#, #handleby.id#)
</insert><insert id="insertUser" parameterClass="user">
insert into USER(ID,NAME, PASSWORD)
values (#id#, #name#, #password#)
</insert>DDL(MySQL):
CREATE TABLE USER (
ID BIGINT NOT NULL,
NAME VARCHAR(255) ,
PASSWORD VARCHAR(255)
);CREATE TABLE ACCOUNT(
ID BIGINT NOT NULL,
NAME VARCHAR(255) ,
DEPOSIT DOUBLE,FK_HANDLEBY BIGINT
);DAO:AccountDao:createAccount(Account account){//get id and set to accountinsert("insertAccount",account);}UserDao:createUser(User user){//get id and set to userinsert("insertUser",user);}Service:AccountService:createNewAccount(Account account){//transaction ignoredDaoManager.getAccountDao().createAccount(account);}Client Call sample (planned):Account account = new Account();account.setName("testAccount");account.setDeposit(new Double(0.0));User user = UserService.getUserByID(new Long(1));//get prepared user object------Ur wrong hereaccount.setHandleby(user);AccountService.createNewAccount(account);Hi Alex,
POJO:
public class Account implements Serializable {
private Long id;
private String name;
private Double deposit;
private int handleby; //modified
}
public class User implements Serializable {
private Long id;
private String username;
private String password;
}
SQL:
<insert id="insertAccount" parameterClass="account">
insert into ACCOUNT (ID,NAME, DEPOSITE, FK_HANDLEBY)
values (#id#, #name#, #deposit#, #handleby#)
</insert><insert id="insertUser" parameterClass="user">
insert into USER(ID,NAME, PASSWORD)
values (#id#, #name#, #password#)
</insert>DDL(MySQL):
CREATE TABLE USER (
ID BIGINT NOT NULL,
NAME VARCHAR(255) ,
PASSWORD VARCHAR(255)
);CREATE TABLE ACCOUNT(
ID BIGINT NOT NULL,
NAME VARCHAR(255) ,
DEPOSIT DOUBLE,FK_HANDLEBY BIGINT
);DAO:AccountDao:createAccount(Account account){//get id and set to accountinsert("insertAccount",account);}UserDao:createUser(User user){//get id and set to userinsert("insertUser",user);}Service:AccountService:createNewAccount(Account account){//transaction ignoredDaoManager.getAccountDao().createAccount(account);}Client Call sample (planned):Account account = new Account();account.setName("testAccount");account.setDeposit(new Double(0.0));int handlebyid = UserService.getUserByID();account.setHandleby(handlebyid );AccountService.createNewAccount(account);Now it'll works.Tx,Patel.
--
借鉴/思考/执行/检验/推广
--
借鉴/思考/执行/检验/推广
