Annotation @Insert List of object

18 views
Skip to first unread message

Jean-Baptiste Dioli

unread,
Aug 20, 2019, 5:04:05 AM8/20/19
to mybatis-user
Hello everyone :) 

Maybe someone can help me or redirect me to the correct post. 

I would like, with annotation insert a list of object. 

There is some of the code: 
------------------------------------------------------------------------------------------------------------------------ 
@Insert("INSERT INTO table1 SET `date` = #{date}") 
@SelectKey(statement="SELECT LAST_INSERT_ID()", before=false, resultType=int.class, keyProperty = "id", keyColumn="id") 
void save(InfoEntity infoEntity); 
------------------------------------------------------------------------------------------------------------------------ 

Thanks a lot !! :) 


@Insert("INSERT INTO table2  (idInfo, sescription) VALUES ( 

           .... Some more code ..... 

#{details.idInfo},  #{details.description})") 
void saveDetails(@Param("details") List<DetailsEntity> detailsEntity); 

Guy Rouillier

unread,
Aug 20, 2019, 9:10:10 PM8/20/19
to mybatis-user

On 8/20/2019 5:04:05 AM, "Jean-Baptiste Dioli" <jdeo...@gmail.com> wrote:

Hello everyone :) 

Maybe someone can help me or redirect me to the correct post. 

I would like, with annotation insert a list of object. 

There is some of the code: 
------------------------------------------------------------------------------------------------------------------------ 
@Insert("INSERT INTO table1 SET `date` = #8/20/2019") 

@SelectKey(statement="SELECT LAST_INSERT_ID()", before=false, resultType=int.class, keyProperty = "id", keyColumn="id") 
void save(InfoEntity infoEntity); 
------------------------------------------------------------------------------------------------------------------------ 

Thanks a lot !! :) 


@Insert("INSERT INTO table2  (idInfo, sescription) VALUES ( 

           .... Some more code ..... 

#{details.idInfo},  #{details.description})") 
void saveDetails(@Param("details") List<DetailsEntity> detailsEntity); 

--
You received this message because you are subscribed to the Google Groups "mybatis-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mybatis-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/mybatis-user/70b328db-aea7-44d8-b075-676765e85cc5%40googlegroups.com.

Jean-Baptiste Dioli

unread,
Aug 21, 2019, 3:42:57 AM8/21/19
to mybatis-user
Thanks Guy!!

There is also this port I've open and that is very interesting. 





Le mercredi 21 août 2019 03:10:10 UTC+2, Guy Rouillier a écrit :

--
Guy Rouillier

On 8/20/2019 5:04:05 AM, "Jean-Baptiste Dioli" <jdeo...@gmail.com> wrote:

Hello everyone :) 

Maybe someone can help me or redirect me to the correct post. 

I would like, with annotation insert a list of object. 

There is some of the code: 
------------------------------------------------------------------------------------------------------------------------ 
@Insert("INSERT INTO table1 SET `date` = #8/20/2019") 
@SelectKey(statement="SELECT LAST_INSERT_ID()", before=false, resultType=int.class, keyProperty = "id", keyColumn="id") 
void save(InfoEntity infoEntity); 
------------------------------------------------------------------------------------------------------------------------ 

Thanks a lot !! :) 


@Insert("INSERT INTO table2  (idInfo, sescription) VALUES ( 

           .... Some more code ..... 

#{details.idInfo},  #{details.description})") 
void saveDetails(@Param("details") List<DetailsEntity> detailsEntity); 

--
You received this message because you are subscribed to the Google Groups "mybatis-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mybati...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages