2016-08-01ãã1ã¶æéã®è¨äºä¸è¦§
ãã¼ã¿ãã¼ã¹ã¸ã®ã¯ã¨ãªã®ã¿ã¤ãã³ã°ãå®ç¾©ããã¨ãã大ããåãã¦ï¼ã¤æ¹å¼ãããã Lazy Fetchï¼é¢é£ããã³ã¬ã¯ã·ã§ã³ãDBããå¼ã³ãã¾ãªããPersistentãªãã¸ã§ã¯ãã«ã³ã¬ã¯ã·ã§ã³ãåå¾ããã¡ã½ãããå¼ã°ããã¨ãã«SQLãçºè¡ãã¦DBããã¬ã³ã¼ããèªã¿è¾¼â¦
ï¼å¯¾å¤ã«ã¤ãã¦ã¯ãåæ¹åã»åæ¹åã»JoinTableã®ï¼ã¤ã®æ¹å¼ãããã â¡åæ¹å Ordersãªãã¸ã§ã¯ãããProductãªãã¸ã§ã¯ãã«å¯¾ãã¦ã®ã¿ã¢ã¯ã»ã¹ããç¶æ public class Orders implements Serializable { @Id @GeneratedValue(strategy = GenerationType.AUTO)â¦
ã«ã¹ã±ã¼ãã¯ãé¢é£ãããEntityã«å¯¾ãã¦è¡ãããå¦çãä¼æããããã¨ãã§ããã ä¾ãã°ãåæ¹åã®1対1ãèããã¨ãããªãã¸ã§ã¯ãä¸ã§Categoryã¤ã³ã¹ã¿ã³ã¹ãä¿åããå ´åã¯ãé¢é£ããSubCategoryã®ã¤ã³ã¹ã¿ã³ã¹ã®ä¿åãèªåã§è¡ãããã â¡PERSISTå¦ç pubâ¦
Hibernateã§ã®çµåãã¼ãã«ã®èªåçæ @JoinTable(name = "category_subcategory", joinColumns = @JoinColumn(name = "category_id"), inverseJoinColumns = @JoinColumn(name = "subcategory_id")) private SubCategory subCategory; joinColumnsï¼ææè â¦