Open GoogleCodeExporter opened 9 years ago
You can accomplish this now without XML:
@Select("SELECT * FROM LOG)
@Results ({
@Result(column="DATE", property="date"),
@Result(column="TIME", property="time"),
@Result(column="FIRST_NAME", property="user.firstName"),
@Result(column="LAST_NAME", property="user.lastName")
})
List<Log> selectAllLogs();
Original comment by jeffgbut...@gmail.com
on 22 Feb 2013 at 7:45
Yes, I agree that using the @Results annotation is a solution, but it is not
reusable. I have to copy and paste it above every method that uses that
mapping. By having the mapping defined inside the class, the mapping then
becomes reusable. All we would beed to do is pass the class into an annotation
above each method. It makes the code cleaner and easy to maintain. That way if
something in my mapping were to change, i would just go into the class and
change the rules, verses changes every @Results annotation.
Original comment by patrick....@gmail.com
on 22 Feb 2013 at 8:26
OK. I understand the concept.
I think there might be an easier way to deal with this if we could name the
result map created with annotations on one method and then refer to it with the
existing @ResultMap annotation. This would be equivalent function to the XML
and would avoid putting MyBatis annotations in your domain objects - which I
think would be a good goal.
WDYT?
Original comment by jeffgbut...@gmail.com
on 23 Feb 2013 at 2:21
That sounds good to me. I would consider that a good solution to my problem.
Original comment by patrick....@gmail.com
on 23 Feb 2013 at 11:22
yes, i agree with you patrick, Iam new in mybatis. that ide look good and less
code in xml
Original comment by abion...@gmail.com
on 3 May 2014 at 11:14
Any traction on this?
Original comment by pe...@club-os.com
on 10 Jul 2014 at 3:27
Original issue reported on code.google.com by
patrick....@gmail.com
on 14 Feb 2013 at 3:14