ã¯ããã¦ã®S2Dao.NETãã®ï¼
è¤æ°ãã¼ãã«ããªã³ã¯ããå ´åã§ããã
ãã¥ã¼ã®ãããªä»®æ³çãªDTOãä½æãã¦èªç±ã«ãããã³ã°ãããã¨ããæ¹æ³ãããã¾ãããã®å ´åã¯SQLã®èªåçæã¯ä½¿ãã¾ãããã»ã»
id:sugimotokazuyaããã«æãã¦é ããã®ã§ãæ©éå®é¨ã§ãã
ã¾ãã¯ãä»®æ³çãªDTOãä½æãã¾ãã
[Table("Grandchild")] public class GrandchildDto { private int id; private string name; private int cid; private string cname; private int pid; private string pname; public int ID { get { return id; } set { id = value; } } public string Name { get { return name; } set { name = value; } } public int CID { get { return cid; } set { cid = value; } } public string CName { get { return cname; } set { cname = value; } } public int PID { get { return pid; } set { pid = value; } } public string PName { get { return pname; } set { pname = value; } } public override string ToString () { return String.Format ("{0}:{1}", ID, Name); } }
親ãåãå«ãã¼ãã«ã®è¦ç´ ãå ¨ã¦éããDTOã«ãã¦ãã¾ãã次ã«ãããããåå¾ããSQLã¯èªåçæåºæ¥ãªãã®ã§ãèªåã§æå®ãããã¨ã«ãªãã¾ããJavaçã§ã¯SQLãã¡ã¤ã«ãä½æãã¾ããã.NETã§ã¯SQLãã¡ã¤ã«ããªã½ã¼ã¹ã¨ãã¦åãè¾¼ãå¿ è¦ãããã¾ããã¾ããSQLãã¡ã¤ã«ã«ã¯ãã¼ãã³ã°ã«ã¼ã«ããã£ã¦ãDAOã¤ã³ã¿ãã§ã¼ã¹ã®å®å ¨å_ã¡ã½ããå.sqlã¨ããªããã°ãªãã¾ãããä¾ãã°ã
using System; using System.Collections; using Seasar.Dao.Attrs; namespace HelloDao3 { [Bean(typeof(GrandchildDto))] public interface IGrandchildDtoDao { IList GetAllList(); [Query("id=/*id*/")] Grandchild GetGrandchildDtoByID(int id); } }
ãã®ã¤ã³ã¿ãã§ã¼ã¹ã®GetAllListã¡ã½ããã«å¯¾ããSQLãã¡ã¤ã«ã ã¨ã
IGrandchildDtoDao_GetAllList.sql
ã¨ããååã§ãã¡ã¤ã«ãä½æãã¦åãè¾¼ã¿ã¾ããå®éã«ã¡ã½ããã«å¯¾ããSQLãèªã¿è¾¼ãã¨ãã¯ã¤ã³ã¿ãã§ã¼ã¹å_ã¡ã½ããåã§åãè¾¼ã¿ãªã½ã¼ã¹ãæ¢ãã¾ãã
ã¡ãªã¿ã«SQLãã¡ã¤ã«ã¯ãããªæãã
select g.id, g.name, c.id as cid, c.name as cname, p.id as pid, p.name as pname from grandchild g, child c, parent p where g.cid = c.id and c.pid = p.id
ã¨ããã§ãVisual Studioã使ç¨ãã¦ããå ´åãè½ã¨ãç©´ãããã¾ããSQLãã¡ã¤ã«ãåãè¾¼ãæã«ããªã½ã¼ã¹åã«ããã©ã«ãã®åå空éãã¤ãã¦ãã¾ãã¾ããä¾ãã°ãä»åã®å ´åã ã¨ãHelloDao3.IGrandchildDtoDao_GetAllList.sql(HelloDao3ãããã©ã«ãã®åå空é)ã¨ãªã£ã¦ãã¾ãã¾ãããããã¤ã³ã¿ãã§ã¼ã¹IGrandchildDtoDaoãç°ãªãåå空éã«å±ãã¦ããããåãè¾¼ã¿ãã¡ã¤ã«ãè¦ã¤ãããã¨ãåºæ¥ã¾ããããªã®ã§ãVisual Studioã§ä½æ¥ããå ´åã¯ãåºæ¬çã«ã¤ã³ã¿ãã§ã¼ã¹ãããã©ã«ãã®åå空éã«æå±ãããå¿ è¦ãããã¾ãã
ããã©ã«ãã®åå空éã¯çµæ§åµãã®ã§åºæ¥ãã°ç¡å¹ã«ããããã§ãããæªå ¥åã«åºæ¥ãªããã§ãããã»ã»ã»