ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Michael Campbell <michael.campb...@gmail.com>
Subject Re: how can i get attribute from inbed object?
Date Sat, 19 Nov 2005 16:40:56 GMT
If "id" in your POJO isn't populated, you either need to let the
database generate one for you or you provide a value.

If you're letting the db do it for you, you don't include the id in
your insert sql at all, but rather use the <selectKey> clause of the
<insert> statement to get the db-generated id back to your POJO.

On 11/19/05, Alex Chew <chew.alex@gmail.com> wrote:
>  Hi, all
>  would you please help me for following issue, thanks advance.
>  POJO:
> public class Account implements Serializable {
>  private Long id;
>  private String name;
> private Double deposit;
>  private User handledby;
> }
>  public class User implements Serializable {
>  private Long id;
>  private String username;
> private String password;
> }
>  SQL:
>  <insert id=3D"insertAccount" parameterClass=3D"account">
> values (#id#, #name#, #deposit#, #handleby.id#)
> </insert>
> handleby.id cannot work,the value inserted is NULL, and no other excpetion
> message.
> Must i get id of handleby
> User manually?
> regards
> Alex

I tend to view "truly flexible" by another term: "Make everything
equally hard". -- DHH

View raw message