hibernate主键

来源:互联网 发布:先知者软件下载 编辑:程序博客网 时间:2024/05/17 01:10
<span style="color: rgb(102, 102, 102); font-family: Helvetica, Tahoma, Arial, sans-serif; font-size: 14px; line-height: 25px;">一、JPA通用策略生成器 通过annotation来映射hibernate实体的,基于annotation的hibernate主键标识为@Id, 其生成规则由@GeneratedValue设定的.这里的@id和@GeneratedValue都是JPA的标准用法, JPA提供四种标准用法,由@GeneratedValue的源代码可以明显看出. </span><span style="color: rgb(85, 85, 85); font-family: 'microsoft yahei'; font-size: 15px; line-height: 35px;"></span><div class="dp-highlighter" id="" style="font-family: Monaco, 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', Consolas, 'Courier New', monospace; width: 659px; overflow: auto; padding: 1px; margin-left: 9px; border-color: rgb(204, 204, 204); color: rgb(85, 85, 85); line-height: 35px; word-break: break-all; word-wrap: break-word; margin-top: 18px !important; margin-right: 0px !important; margin-bottom: 18px !important; background-color: transparent;"><div class="bar" style="padding-left: 45px;"><div class="tools" style="padding: 3px; font-weight: bold; font-stretch: normal; font-size: 9px; line-height: normal; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; color: black; border-left-width: 3px; border-left-style: solid; border-left-color: rgb(108, 226, 108); margin: 0px; background-color: rgb(248, 248, 248);">Java代码  <a target=_blank href="http://xiaogui9317170.iteye.com/blog/283526" title="收藏这段代码" style="text-decoration: none; border: none; padding: 1px; margin: 0px 10px 0px 0px; font-size: 9px; color: rgb(0, 102, 153); display: inline-block; width: 16px; height: 16px; text-indent: -2000px; background-image: none; background-attachment: initial; background-color: inherit; background-size: initial; background-origin: initial; background-clip: initial; background-position: 0% 0%; background-repeat: no-repeat;"><img class="star" src="http://xiaogui9317170.iteye.com/images/icon_star.png" alt="收藏代码" style="border: 0px;" /></a></div></div><ol start="1" class="dp-j" style="margin: 0px 0px 1px; padding: 2px 0px; border: 1px solid rgb(209, 215, 220); list-style-position: initial; list-style-image: initial; color: rgb(43, 145, 175); font-size: 1em; line-height: 1.4em;"><li style="margin: 0px 0px 0px 38px; padding: 0px 0px 0px 10px; border-style: none none none solid; border-left-width: 1px; border-left-color: rgb(209, 215, 220); list-style: decimal-leading-zero outside; color: rgb(92, 92, 92); line-height: 18px; font-size: 1em; background-color: rgb(250, 250, 250);"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;"><span class="annotation" style="margin: 0px; padding: 0px; border: none; color: rgb(100, 100, 100); background-color: inherit;">@Target</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">({METHOD,FIELD})    </span></span></li><li style="margin: 0px 0px 0px 38px; padding: 0px 0px 0px 10px; border-style: none none none solid; border-left-width: 1px; border-left-color: rgb(209, 215, 220); list-style: decimal-leading-zero outside; color: rgb(92, 92, 92); line-height: 18px; font-size: 1em; background-color: rgb(250, 250, 250);"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;">    <span class="annotation" style="margin: 0px; padding: 0px; border: none; color: rgb(100, 100, 100); background-color: inherit;">@Retention</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">(RUNTIME)    </span></span></li><li style="margin: 0px 0px 0px 38px; padding: 0px 0px 0px 10px; border-style: none none none solid; border-left-width: 1px; border-left-color: rgb(209, 215, 220); list-style: decimal-leading-zero outside; color: rgb(92, 92, 92); line-height: 18px; font-size: 1em; background-color: rgb(250, 250, 250);"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;">    <span class="keyword" style="margin: 0px; padding: 0px; border: none; color: rgb(127, 0, 85); font-weight: bold; background-color: inherit;">public</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;"> </span><span class="keyword" style="margin: 0px; padding: 0px; border: none; color: rgb(127, 0, 85); font-weight: bold; background-color: inherit;">@interface</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;"> GeneratedValue{    </span></span></li><li style="margin: 0px 0px 0px 38px; padding: 0px 0px 0px 10px; border-style: none none none solid; border-left-width: 1px; border-left-color: rgb(209, 215, 220); list-style: decimal-leading-zero outside; color: rgb(92, 92, 92); line-height: 18px; font-size: 1em; background-color: rgb(250, 250, 250);"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;">        GenerationType strategy() <span class="keyword" style="margin: 0px; padding: 0px; border: none; color: rgb(127, 0, 85); font-weight: bold; background-color: inherit;">default</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;"> AUTO;    </span></span></li><li style="margin: 0px 0px 0px 38px; padding: 0px 0px 0px 10px; border-style: none none none solid; border-left-width: 1px; border-left-color: rgb(209, 215, 220); list-style: decimal-leading-zero outside; color: rgb(92, 92, 92); line-height: 18px; font-size: 1em; background-color: rgb(250, 250, 250);"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;">        String generator() <span class="keyword" style="margin: 0px; padding: 0px; border: none; color: rgb(127, 0, 85); font-weight: bold; background-color: inherit;">default</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;"> </span><span class="string" style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit;">""</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">;    </span></span></li><li style="margin: 0px 0px 0px 38px; padding: 0px 0px 0px 10px; border-style: none none none solid; border-left-width: 1px; border-left-color: rgb(209, 215, 220); list-style: decimal-leading-zero outside; color: rgb(92, 92, 92); line-height: 18px; font-size: 1em; background-color: rgb(250, 250, 250);"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;">    }   </span></li></ol></div><br style="color: rgb(85, 85, 85); font-family: 'microsoft yahei'; font-size: 15px; line-height: 35px;" /><br style="color: rgb(85, 85, 85); font-family: 'microsoft yahei'; font-size: 15px; line-height: 35px;" /><span style="color: rgb(85, 85, 85); font-family: 'microsoft yahei'; font-size: 15px; line-height: 35px;">其中GenerationType: </span><br style="color: rgb(85, 85, 85); font-family: 'microsoft yahei'; font-size: 15px; line-height: 35px;" /><br style="color: rgb(85, 85, 85); font-family: 'microsoft yahei'; font-size: 15px; line-height: 35px;" /><div class="dp-highlighter" id="" style="font-family: Monaco, 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', Consolas, 'Courier New', monospace; width: 659px; overflow: auto; padding: 1px; margin-left: 9px; border-color: rgb(204, 204, 204); color: rgb(85, 85, 85); line-height: 35px; word-break: break-all; word-wrap: break-word; margin-top: 18px !important; margin-right: 0px !important; margin-bottom: 18px !important; background-color: transparent;"><div class="bar" style="padding-left: 45px;"><div class="tools" style="padding: 3px; font-weight: bold; font-stretch: normal; font-size: 9px; line-height: normal; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; color: black; border-left-width: 3px; border-left-style: solid; border-left-color: rgb(108, 226, 108); margin: 0px; background-color: rgb(248, 248, 248);">Java代码  <a target=_blank href="http://xiaogui9317170.iteye.com/blog/283526" title="收藏这段代码" style="text-decoration: none; border: none; padding: 1px; margin: 0px 10px 0px 0px; font-size: 9px; color: rgb(0, 102, 153); display: inline-block; width: 16px; height: 16px; text-indent: -2000px; background-image: none; background-attachment: initial; background-color: inherit; background-size: initial; background-origin: initial; background-clip: initial; background-position: 0% 0%; background-repeat: no-repeat;"><img class="star" src="http://xiaogui9317170.iteye.com/images/icon_star.png" alt="收藏代码" style="border: 0px;" /></a></div></div><ol start="1" class="dp-j" style="margin: 0px 0px 1px; padding: 2px 0px; border: 1px solid rgb(209, 215, 220); list-style-position: initial; list-style-image: initial; color: rgb(43, 145, 175); font-size: 1em; line-height: 1.4em;"><li style="margin: 0px 0px 0px 38px; padding: 0px 0px 0px 10px; border-style: none none none solid; border-left-width: 1px; border-left-color: rgb(209, 215, 220); list-style: decimal-leading-zero outside; color: rgb(92, 92, 92); line-height: 18px; font-size: 1em; background-color: rgb(250, 250, 250);"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;"><span class="keyword" style="margin: 0px; padding: 0px; border: none; color: rgb(127, 0, 85); font-weight: bold; background-color: inherit;">public</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;"> </span><span class="keyword" style="margin: 0px; padding: 0px; border: none; color: rgb(127, 0, 85); font-weight: bold; background-color: inherit;">enum</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;"> GenerationType{    </span></span></li><li style="margin: 0px 0px 0px 38px; padding: 0px 0px 0px 10px; border-style: none none none solid; border-left-width: 1px; border-left-color: rgb(209, 215, 220); list-style: decimal-leading-zero outside; color: rgb(92, 92, 92); line-height: 18px; font-size: 1em; background-color: rgb(250, 250, 250);"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;">    TABLE,    </span></li><li style="margin: 0px 0px 0px 38px; padding: 0px 0px 0px 10px; border-style: none none none solid; border-left-width: 1px; border-left-color: rgb(209, 215, 220); list-style: decimal-leading-zero outside; color: rgb(92, 92, 92); line-height: 18px; font-size: 1em; background-color: rgb(250, 250, 250);"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;">    SEQUENCE,    </span></li><li style="margin: 0px 0px 0px 38px; padding: 0px 0px 0px 10px; border-style: none none none solid; border-left-width: 1px; border-left-color: rgb(209, 215, 220); list-style: decimal-leading-zero outside; color: rgb(92, 92, 92); line-height: 18px; font-size: 1em; background-color: rgb(250, 250, 250);"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;">    IDENTITY,    </span></li><li style="margin: 0px 0px 0px 38px; padding: 0px 0px 0px 10px; border-style: none none none solid; border-left-width: 1px; border-left-color: rgb(209, 215, 220); list-style: decimal-leading-zero outside; color: rgb(92, 92, 92); line-height: 18px; font-size: 1em; background-color: rgb(250, 250, 250);"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;">    AUTO   </span></li><li style="margin: 0px 0px 0px 38px; padding: 0px 0px 0px 10px; border-style: none none none solid; border-left-width: 1px; border-left-color: rgb(209, 215, 220); list-style: decimal-leading-zero outside; color: rgb(92, 92, 92); line-height: 18px; font-size: 1em; background-color: rgb(250, 250, 250);"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;">}  </span></li></ol></div><br style="color: rgb(85, 85, 85); font-family: 'microsoft yahei'; font-size: 15px; line-height: 35px;" /><br style="color: rgb(85, 85, 85); font-family: 'microsoft yahei'; font-size: 15px; line-height: 35px;" /><span style="color: rgb(85, 85, 85); font-family: 'microsoft yahei'; font-size: 15px; line-height: 35px;">JPA提供的四种标准用法为TABLE,SEQUENCE,IDENTITY,AUTO. </span><br style="color: rgb(85, 85, 85); font-family: 'microsoft yahei'; font-size: 15px; line-height: 35px;" /><span style="color: rgb(85, 85, 85); font-family: 'microsoft yahei'; font-size: 15px; line-height: 35px;">TABLE:使用一个特定的数据库表格来保存主键。 </span><br style="color: rgb(85, 85, 85); font-family: 'microsoft yahei'; font-size: 15px; line-height: 35px;" /><span style="color: rgb(85, 85, 85); font-family: 'microsoft yahei'; font-size: 15px; line-height: 35px;">SEQUENCE:根据底层数据库的序列来生成主键,条件是数据库支持序列。 </span><br style="color: rgb(85, 85, 85); font-family: 'microsoft yahei'; font-size: 15px; line-height: 35px;" /><span style="color: rgb(85, 85, 85); font-family: 'microsoft yahei'; font-size: 15px; line-height: 35px;">IDENTITY:主键由数据库自动生成(主要是自动增长型) </span><br style="color: rgb(85, 85, 85); font-family: 'microsoft yahei'; font-size: 15px; line-height: 35px;" /><span style="color: rgb(85, 85, 85); font-family: 'microsoft yahei'; font-size: 15px; line-height: 35px;">AUTO:主键由程序控制。 </span><br style="color: rgb(85, 85, 85); font-family: 'microsoft yahei'; font-size: 15px; line-height: 35px;" /><br style="color: rgb(85, 85, 85); font-family: 'microsoft yahei'; font-size: 15px; line-height: 35px;" /><span style="color: rgb(85, 85, 85); font-family: 'microsoft yahei'; font-size: 15px; line-height: 35px;">1、TABLE </span><br style="color: rgb(85, 85, 85); font-family: 'microsoft yahei'; font-size: 15px; line-height: 35px;" /><div class="dp-highlighter" id="" style="font-family: Monaco, 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', Consolas, 'Courier New', monospace; width: 659px; overflow: auto; padding: 1px; margin-left: 9px; border-color: rgb(204, 204, 204); color: rgb(85, 85, 85); line-height: 35px; word-break: break-all; word-wrap: break-word; margin-top: 18px !important; margin-right: 0px !important; margin-bottom: 18px !important; background-color: transparent;"><div class="bar" style="padding-left: 45px;"><div class="tools" style="padding: 3px; font-weight: bold; font-stretch: normal; font-size: 9px; line-height: normal; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; color: black; border-left-width: 3px; border-left-style: solid; border-left-color: rgb(108, 226, 108); margin: 0px; background-color: rgb(248, 248, 248);">Java代码  <a target=_blank href="http://xiaogui9317170.iteye.com/blog/283526" title="收藏这段代码" style="text-decoration: none; border: none; padding: 1px; margin: 0px 10px 0px 0px; font-size: 9px; color: rgb(0, 102, 153); display: inline-block; width: 16px; height: 16px; text-indent: -2000px; background-image: none; background-attachment: initial; background-color: inherit; background-size: initial; background-origin: initial; background-clip: initial; background-position: 0% 0%; background-repeat: no-repeat;"><img class="star" src="http://xiaogui9317170.iteye.com/images/icon_star.png" alt="收藏代码" style="border: 0px;" /></a></div></div><ol start="1" class="dp-j" style="margin: 0px 0px 1px; padding: 2px 0px; border: 1px solid rgb(209, 215, 220); list-style-position: initial; list-style-image: initial; color: rgb(43, 145, 175); font-size: 1em; line-height: 1.4em;"><li style="margin: 0px 0px 0px 38px; padding: 0px 0px 0px 10px; border-style: none none none solid; border-left-width: 1px; border-left-color: rgb(209, 215, 220); list-style: decimal-leading-zero outside; color: rgb(92, 92, 92); line-height: 18px; font-size: 1em; background-color: rgb(250, 250, 250);"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;"><span class="annotation" style="margin: 0px; padding: 0px; border: none; color: rgb(100, 100, 100); background-color: inherit;">@Id</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">  </span></span></li><li style="margin: 0px 0px 0px 38px; padding: 0px 0px 0px 10px; border-style: none none none solid; border-left-width: 1px; border-left-color: rgb(209, 215, 220); list-style: decimal-leading-zero outside; color: rgb(92, 92, 92); line-height: 18px; font-size: 1em; background-color: rgb(250, 250, 250);"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;"><span class="annotation" style="margin: 0px; padding: 0px; border: none; color: rgb(100, 100, 100); background-color: inherit;">@GeneratedValue</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">(strategy = GenerationType.TABLE, generator=</span><span class="string" style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit;">"payablemoney_gen"</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">)  </span></span></li><li style="margin: 0px 0px 0px 38px; padding: 0px 0px 0px 10px; border-style: none none none solid; border-left-width: 1px; border-left-color: rgb(209, 215, 220); list-style: decimal-leading-zero outside; color: rgb(92, 92, 92); line-height: 18px; font-size: 1em; background-color: rgb(250, 250, 250);"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;"><span class="annotation" style="margin: 0px; padding: 0px; border: none; color: rgb(100, 100, 100); background-color: inherit;">@TableGenerator</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">(name = </span><span class="string" style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit;">"pk_gen"</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">,  </span></span></li><li style="margin: 0px 0px 0px 38px; padding: 0px 0px 0px 10px; border-style: none none none solid; border-left-width: 1px; border-left-color: rgb(209, 215, 220); list-style: decimal-leading-zero outside; color: rgb(92, 92, 92); line-height: 18px; font-size: 1em; background-color: rgb(250, 250, 250);"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;">    table=<span class="string" style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit;">"tb_generator"</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">,  </span></span></li><li style="margin: 0px 0px 0px 38px; padding: 0px 0px 0px 10px; border-style: none none none solid; border-left-width: 1px; border-left-color: rgb(209, 215, 220); list-style: decimal-leading-zero outside; color: rgb(92, 92, 92); line-height: 18px; font-size: 1em; background-color: rgb(250, 250, 250);"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;">    pkColumnName=<span class="string" style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit;">"gen_name"</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">,  </span></span></li><li style="margin: 0px 0px 0px 38px; padding: 0px 0px 0px 10px; border-style: none none none solid; border-left-width: 1px; border-left-color: rgb(209, 215, 220); list-style: decimal-leading-zero outside; color: rgb(92, 92, 92); line-height: 18px; font-size: 1em; background-color: rgb(250, 250, 250);"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;">    valueColumnName=<span class="string" style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit;">"gen_value"</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">,  </span></span></li><li style="margin: 0px 0px 0px 38px; padding: 0px 0px 0px 10px; border-style: none none none solid; border-left-width: 1px; border-left-color: rgb(209, 215, 220); list-style: decimal-leading-zero outside; color: rgb(92, 92, 92); line-height: 18px; font-size: 1em; background-color: rgb(250, 250, 250);"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;">    pkColumnValue=<span class="string" style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit;">"PAYABLEMOENY_PK"</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">,  </span></span></li><li style="margin: 0px 0px 0px 38px; padding: 0px 0px 0px 10px; border-style: none none none solid; border-left-width: 1px; border-left-color: rgb(209, 215, 220); list-style: decimal-leading-zero outside; color: rgb(92, 92, 92); line-height: 18px; font-size: 1em; background-color: rgb(250, 250, 250);"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;">    allocationSize=<span class="number" style="margin: 0px; padding: 0px; border: none; color: rgb(192, 0, 0); background-color: inherit;">1</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">  </span></span></li><li style="margin: 0px 0px 0px 38px; padding: 0px 0px 0px 10px; border-style: none none none solid; border-left-width: 1px; border-left-color: rgb(209, 215, 220); list-style: decimal-leading-zero outside; color: rgb(92, 92, 92); line-height: 18px; font-size: 1em; background-color: rgb(250, 250, 250);"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;">)  </span></li></ol></div><br style="color: rgb(85, 85, 85); font-family: 'microsoft yahei'; font-size: 15px; line-height: 35px;" /><br style="color: rgb(85, 85, 85); font-family: 'microsoft yahei'; font-size: 15px; line-height: 35px;" /><span style="color: rgb(85, 85, 85); font-family: 'microsoft yahei'; font-size: 15px; line-height: 35px;">这里应用表tb_generator,定义为 </span><br style="color: rgb(85, 85, 85); font-family: 'microsoft yahei'; font-size: 15px; line-height: 35px;" /><div class="dp-highlighter" id="" style="font-family: Monaco, 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', Consolas, 'Courier New', monospace; width: 659px; overflow: auto; padding: 1px; margin-left: 9px; border-color: rgb(204, 204, 204); color: rgb(85, 85, 85); line-height: 35px; word-break: break-all; word-wrap: break-word; margin-top: 18px !important; margin-right: 0px !important; margin-bottom: 18px !important; background-color: transparent;"><div class="bar" style="padding-left: 45px;"><div class="tools" style="padding: 3px; font-weight: bold; font-stretch: normal; font-size: 9px; line-height: normal; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; color: black; border-left-width: 3px; border-left-style: solid; border-left-color: rgb(108, 226, 108); margin: 0px; background-color: rgb(248, 248, 248);">Sql代码  <a target=_blank href="http://xiaogui9317170.iteye.com/blog/283526" title="收藏这段代码" style="text-decoration: none; border: none; padding: 1px; margin: 0px 10px 0px 0px; font-size: 9px; color: rgb(0, 102, 153); display: inline-block; width: 16px; height: 16px; text-indent: -2000px; background-image: none; background-attachment: initial; background-color: inherit; background-size: initial; background-origin: initial; background-clip: initial; background-position: 0% 0%; background-repeat: no-repeat;"><img class="star" src="http://xiaogui9317170.iteye.com/images/icon_star.png" alt="收藏代码" style="border: 0px;" /></a></div></div><ol start="1" class="dp-sql" style="margin: 0px 0px 1px; padding: 2px 0px; border: 1px solid rgb(209, 215, 220); list-style-position: initial; list-style-image: initial; color: rgb(43, 145, 175); font-size: 1em; line-height: 1.4em;"><li style="margin: 0px 0px 0px 38px; padding: 0px 0px 0px 10px; border-style: none none none solid; border-left-width: 1px; border-left-color: rgb(209, 215, 220); list-style: decimal-leading-zero outside; color: rgb(92, 92, 92); line-height: 18px; font-size: 1em; background-color: rgb(250, 250, 250);"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;"><span class="keyword" style="margin: 0px; padding: 0px; border: none; color: rgb(127, 0, 85); font-weight: bold; background-color: inherit;">CREATE</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;"> </span><span class="keyword" style="margin: 0px; padding: 0px; border: none; color: rgb(127, 0, 85); font-weight: bold; background-color: inherit;">TABLE</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">  tb_generator (  </span></span></li><li style="margin: 0px 0px 0px 38px; padding: 0px 0px 0px 10px; border-style: none none none solid; border-left-width: 1px; border-left-color: rgb(209, 215, 220); list-style: decimal-leading-zero outside; color: rgb(92, 92, 92); line-height: 18px; font-size: 1em; background-color: rgb(250, 250, 250);"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;">  id NUMBER <span class="op" style="margin: 0px; padding: 0px; border: none; color: rgb(128, 128, 128); background-color: inherit;">NOT</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;"> </span><span class="op" style="margin: 0px; padding: 0px; border: none; color: rgb(128, 128, 128); background-color: inherit;">NULL</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">,  </span></span></li><li style="margin: 0px 0px 0px 38px; padding: 0px 0px 0px 10px; border-style: none none none solid; border-left-width: 1px; border-left-color: rgb(209, 215, 220); list-style: decimal-leading-zero outside; color: rgb(92, 92, 92); line-height: 18px; font-size: 1em; background-color: rgb(250, 250, 250);"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;">  gen_name VARCHAR2(255) <span class="op" style="margin: 0px; padding: 0px; border: none; color: rgb(128, 128, 128); background-color: inherit;">NOT</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;"> </span><span class="op" style="margin: 0px; padding: 0px; border: none; color: rgb(128, 128, 128); background-color: inherit;">NULL</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">,  </span></span></li><li style="margin: 0px 0px 0px 38px; padding: 0px 0px 0px 10px; border-style: none none none solid; border-left-width: 1px; border-left-color: rgb(209, 215, 220); list-style: decimal-leading-zero outside; color: rgb(92, 92, 92); line-height: 18px; font-size: 1em; background-color: rgb(250, 250, 250);"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;">  gen_value NUMBER <span class="op" style="margin: 0px; padding: 0px; border: none; color: rgb(128, 128, 128); background-color: inherit;">NOT</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;"> </span><span class="op" style="margin: 0px; padding: 0px; border: none; color: rgb(128, 128, 128); background-color: inherit;">NULL</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">,  </span></span></li><li style="margin: 0px 0px 0px 38px; padding: 0px 0px 0px 10px; border-style: none none none solid; border-left-width: 1px; border-left-color: rgb(209, 215, 220); list-style: decimal-leading-zero outside; color: rgb(92, 92, 92); line-height: 18px; font-size: 1em; background-color: rgb(250, 250, 250);"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;">  <span class="keyword" style="margin: 0px; padding: 0px; border: none; color: rgb(127, 0, 85); font-weight: bold; background-color: inherit;">PRIMARY</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;"> </span><span class="keyword" style="margin: 0px; padding: 0px; border: none; color: rgb(127, 0, 85); font-weight: bold; background-color: inherit;">KEY</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">(id)  </span></span></li><li style="margin: 0px 0px 0px 38px; padding: 0px 0px 0px 10px; border-style: none none none solid; border-left-width: 1px; border-left-color: rgb(209, 215, 220); list-style: decimal-leading-zero outside; color: rgb(92, 92, 92); line-height: 18px; font-size: 1em; background-color: rgb(250, 250, 250);"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;">)  </span></li></ol></div><br style="color: rgb(85, 85, 85); font-family: 'microsoft yahei'; font-size: 15px; line-height: 35px;" /><br style="color: rgb(85, 85, 85); font-family: 'microsoft yahei'; font-size: 15px; line-height: 35px;" /><span style="color: rgb(85, 85, 85); font-family: 'microsoft yahei'; font-size: 15px; line-height: 35px;">插入纪录,供生成主键使用, </span><br style="color: rgb(85, 85, 85); font-family: 'microsoft yahei'; font-size: 15px; line-height: 35px;" /><div class="dp-highlighter" id="" style="font-family: Monaco, 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', Consolas, 'Courier New', monospace; width: 659px; overflow: auto; padding: 1px; margin-left: 9px; border-color: rgb(204, 204, 204); color: rgb(85, 85, 85); line-height: 35px; word-break: break-all; word-wrap: break-word; margin-top: 18px !important; margin-right: 0px !important; margin-bottom: 18px !important; background-color: transparent;"><div class="bar" style="padding-left: 45px;"><div class="tools" style="padding: 3px; font-weight: bold; font-stretch: normal; font-size: 9px; line-height: normal; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; color: black; border-left-width: 3px; border-left-style: solid; border-left-color: rgb(108, 226, 108); margin: 0px; background-color: rgb(248, 248, 248);">Sql代码  <a target=_blank href="http://xiaogui9317170.iteye.com/blog/283526" title="收藏这段代码" style="text-decoration: none; border: none; padding: 1px; margin: 0px 10px 0px 0px; font-size: 9px; color: rgb(0, 102, 153); display: inline-block; width: 16px; height: 16px; text-indent: -2000px; background-image: none; background-attachment: initial; background-color: inherit; background-size: initial; background-origin: initial; background-clip: initial; background-position: 0% 0%; background-repeat: no-repeat;"><img class="star" src="http://xiaogui9317170.iteye.com/images/icon_star.png" alt="收藏代码" style="border: 0px;" /></a></div></div><ol start="1" class="dp-sql" style="margin: 0px 0px 1px; padding: 2px 0px; border: 1px solid rgb(209, 215, 220); list-style-position: initial; list-style-image: initial; color: rgb(43, 145, 175); font-size: 1em; line-height: 1.4em;"><li style="margin: 0px 0px 0px 38px; padding: 0px 0px 0px 10px; border-style: none none none solid; border-left-width: 1px; border-left-color: rgb(209, 215, 220); list-style: decimal-leading-zero outside; color: rgb(92, 92, 92); line-height: 18px; font-size: 1em; background-color: rgb(250, 250, 250);"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;"><span class="keyword" style="margin: 0px; padding: 0px; border: none; color: rgb(127, 0, 85); font-weight: bold; background-color: inherit;">INSERT</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;"> </span><span class="keyword" style="margin: 0px; padding: 0px; border: none; color: rgb(127, 0, 85); font-weight: bold; background-color: inherit;">INTO</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;"> tb_generator(id, gen_name, gen_value) </span><span class="keyword" style="margin: 0px; padding: 0px; border: none; color: rgb(127, 0, 85); font-weight: bold; background-color: inherit;">VALUES</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;"> (1,PAYABLEMOENY_PK', 1);  </span></span></li></ol></div><br style="color: rgb(85, 85, 85); font-family: 'microsoft yahei'; font-size: 15px; line-height: 35px;" /><br style="color: rgb(85, 85, 85); font-family: 'microsoft yahei'; font-size: 15px; line-height: 35px;" /><span style="color: rgb(85, 85, 85); font-family: 'microsoft yahei'; font-size: 15px; line-height: 35px;">在主键生成后,这条纪录的value值,按allocationSize递增。 </span><br style="color: rgb(85, 85, 85); font-family: 'microsoft yahei'; font-size: 15px; line-height: 35px;" /><br style="color: rgb(85, 85, 85); font-family: 'microsoft yahei'; font-size: 15px; line-height: 35px;" /><br style="color: rgb(85, 85, 85); font-family: 'microsoft yahei'; font-size: 15px; line-height: 35px;" /><span style="color: rgb(85, 85, 85); font-family: 'microsoft yahei'; font-size: 15px; line-height: 35px;">@TableGenerator的定义: </span><br style="color: rgb(85, 85, 85); font-family: 'microsoft yahei'; font-size: 15px; line-height: 35px;" /><div class="dp-highlighter" id="" style="font-family: Monaco, 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', Consolas, 'Courier New', monospace; width: 659px; overflow: auto; padding: 1px; margin-left: 9px; border-color: rgb(204, 204, 204); color: rgb(85, 85, 85); line-height: 35px; word-break: break-all; word-wrap: break-word; margin-top: 18px !important; margin-right: 0px !important; margin-bottom: 18px !important; background-color: transparent;"><div class="bar" style="padding-left: 45px;"><div class="tools" style="padding: 3px; font-weight: bold; font-stretch: normal; font-size: 9px; line-height: normal; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; color: black; border-left-width: 3px; border-left-style: solid; border-left-color: rgb(108, 226, 108); margin: 0px; background-color: rgb(248, 248, 248);">Java代码  <a target=_blank href="http://xiaogui9317170.iteye.com/blog/283526" title="收藏这段代码" style="text-decoration: none; border: none; padding: 1px; margin: 0px 10px 0px 0px; font-size: 9px; color: rgb(0, 102, 153); display: inline-block; width: 16px; height: 16px; text-indent: -2000px; background-image: none; background-attachment: initial; background-color: inherit; background-size: initial; background-origin: initial; background-clip: initial; background-position: 0% 0%; background-repeat: no-repeat;"><img class="star" src="http://xiaogui9317170.iteye.com/images/icon_star.png" alt="收藏代码" style="border: 0px;" /></a></div></div><ol start="1" class="dp-j" style="margin: 0px 0px 1px; padding: 2px 0px; border: 1px solid rgb(209, 215, 220); list-style-position: initial; list-style-image: initial; color: rgb(43, 145, 175); font-size: 1em; line-height: 1.4em;"><li style="margin: 0px 0px 0px 38px; padding: 0px 0px 0px 10px; border-style: none none none solid; border-left-width: 1px; border-left-color: rgb(209, 215, 220); list-style: decimal-leading-zero outside; color: rgb(92, 92, 92); line-height: 18px; font-size: 1em; background-color: rgb(250, 250, 250);"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;"><span class="annotation" style="margin: 0px; padding: 0px; border: none; color: rgb(100, 100, 100); background-color: inherit;">@Target</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">({TYPE, METHOD, FIELD})   </span></span></li><li style="margin: 0px 0px 0px 38px; padding: 0px 0px 0px 10px; border-style: none none none solid; border-left-width: 1px; border-left-color: rgb(209, 215, 220); list-style: decimal-leading-zero outside; color: rgb(92, 92, 92); line-height: 18px; font-size: 1em; background-color: rgb(250, 250, 250);"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;"><span class="annotation" style="margin: 0px; padding: 0px; border: none; color: rgb(100, 100, 100); background-color: inherit;">@Retention</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">(RUNTIME)  </span></span></li><li style="margin: 0px 0px 0px 38px; padding: 0px 0px 0px 10px; border-style: none none none solid; border-left-width: 1px; border-left-color: rgb(209, 215, 220); list-style: decimal-leading-zero outside; color: rgb(92, 92, 92); line-height: 18px; font-size: 1em; background-color: rgb(250, 250, 250);"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;"><span class="keyword" style="margin: 0px; padding: 0px; border: none; color: rgb(127, 0, 85); font-weight: bold; background-color: inherit;">public</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;"> </span><span class="keyword" style="margin: 0px; padding: 0px; border: none; color: rgb(127, 0, 85); font-weight: bold; background-color: inherit;">@interface</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;"> TableGenerator {  </span></span></li><li style="margin: 0px 0px 0px 38px; padding: 0px 0px 0px 10px; border-style: none none none solid; border-left-width: 1px; border-left-color: rgb(209, 215, 220); list-style: decimal-leading-zero outside; color: rgb(92, 92, 92); line-height: 18px; font-size: 1em; background-color: rgb(250, 250, 250);"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;">  String name();  </span></li><li style="margin: 0px 0px 0px 38px; padding: 0px 0px 0px 10px; border-style: none none none solid; border-left-width: 1px; border-left-color: rgb(209, 215, 220); list-style: decimal-leading-zero outside; color: rgb(92, 92, 92); line-height: 18px; font-size: 1em; background-color: rgb(250, 250, 250);"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;">  String table() <span class="keyword" style="margin: 0px; padding: 0px; border: none; color: rgb(127, 0, 85); font-weight: bold; background-color: inherit;">default</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;"> </span><span class="string" style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit;">""</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">;  </span></span></li><li style="margin: 0px 0px 0px 38px; padding: 0px 0px 0px 10px; border-style: none none none solid; border-left-width: 1px; border-left-color: rgb(209, 215, 220); list-style: decimal-leading-zero outside; color: rgb(92, 92, 92); line-height: 18px; font-size: 1em; background-color: rgb(250, 250, 250);"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;">  String catalog() <span class="keyword" style="margin: 0px; padding: 0px; border: none; color: rgb(127, 0, 85); font-weight: bold; background-color: inherit;">default</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;"> </span><span class="string" style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit;">""</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">;  </span></span></li><li style="margin: 0px 0px 0px 38px; padding: 0px 0px 0px 10px; border-style: none none none solid; border-left-width: 1px; border-left-color: rgb(209, 215, 220); list-style: decimal-leading-zero outside; color: rgb(92, 92, 92); line-height: 18px; font-size: 1em; background-color: rgb(250, 250, 250);"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;">  String schema() <span class="keyword" style="margin: 0px; padding: 0px; border: none; color: rgb(127, 0, 85); font-weight: bold; background-color: inherit;">default</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;"> </span><span class="string" style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit;">""</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">;  </span></span></li><li style="margin: 0px 0px 0px 38px; padding: 0px 0px 0px 10px; border-style: none none none solid; border-left-width: 1px; border-left-color: rgb(209, 215, 220); list-style: decimal-leading-zero outside; color: rgb(92, 92, 92); line-height: 18px; font-size: 1em; background-color: rgb(250, 250, 250);"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;">  String pkColumnName() <span class="keyword" style="margin: 0px; padding: 0px; border: none; color: rgb(127, 0, 85); font-weight: bold; background-color: inherit;">default</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;"> </span><span class="string" style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit;">""</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">;  </span></span></li><li style="margin: 0px 0px 0px 38px; padding: 0px 0px 0px 10px; border-style: none none none solid; border-left-width: 1px; border-left-color: rgb(209, 215, 220); list-style: decimal-leading-zero outside; color: rgb(92, 92, 92); line-height: 18px; font-size: 1em; background-color: rgb(250, 250, 250);"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;">  String valueColumnName() <span class="keyword" style="margin: 0px; padding: 0px; border: none; color: rgb(127, 0, 85); font-weight: bold; background-color: inherit;">default</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;"> </span><span class="string" style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit;">""</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">;  </span></span></li><li style="margin: 0px 0px 0px 38px; padding: 0px 0px 0px 10px; border-style: none none none solid; border-left-width: 1px; border-left-color: rgb(209, 215, 220); list-style: decimal-leading-zero outside; color: rgb(92, 92, 92); line-height: 18px; font-size: 1em; background-color: rgb(250, 250, 250);"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;">  String pkColumnValue() <span class="keyword" style="margin: 0px; padding: 0px; border: none; color: rgb(127, 0, 85); font-weight: bold; background-color: inherit;">default</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;"> </span><span class="string" style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit;">""</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">;  </span></span></li><li style="margin: 0px 0px 0px 38px; padding: 0px 0px 0px 10px; border-style: none none none solid; border-left-width: 1px; border-left-color: rgb(209, 215, 220); list-style: decimal-leading-zero outside; color: rgb(92, 92, 92); line-height: 18px; font-size: 1em; background-color: rgb(250, 250, 250);"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;">  <span class="keyword" style="margin: 0px; padding: 0px; border: none; color: rgb(127, 0, 85); font-weight: bold; background-color: inherit;">int</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;"> initialValue() </span><span class="keyword" style="margin: 0px; padding: 0px; border: none; color: rgb(127, 0, 85); font-weight: bold; background-color: inherit;">default</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;"> </span><span class="number" style="margin: 0px; padding: 0px; border: none; color: rgb(192, 0, 0); background-color: inherit;">0</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">;  </span></span></li><li style="margin: 0px 0px 0px 38px; padding: 0px 0px 0px 10px; border-style: none none none solid; border-left-width: 1px; border-left-color: rgb(209, 215, 220); list-style: decimal-leading-zero outside; color: rgb(92, 92, 92); line-height: 18px; font-size: 1em; background-color: rgb(250, 250, 250);"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;">  <span class="keyword" style="margin: 0px; padding: 0px; border: none; color: rgb(127, 0, 85); font-weight: bold; background-color: inherit;">int</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;"> allocationSize() </span><span class="keyword" style="margin: 0px; padding: 0px; border: none; color: rgb(127, 0, 85); font-weight: bold; background-color: inherit;">default</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;"> </span><span class="number" style="margin: 0px; padding: 0px; border: none; color: rgb(192, 0, 0); background-color: inherit;">50</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">;  </span></span></li><li style="margin: 0px 0px 0px 38px; padding: 0px 0px 0px 10px; border-style: none none none solid; border-left-width: 1px; border-left-color: rgb(209, 215, 220); list-style: decimal-leading-zero outside; color: rgb(92, 92, 92); line-height: 18px; font-size: 1em; background-color: rgb(250, 250, 250);"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;">  UniqueConstraint[] uniqueConstraints() <span class="keyword" style="margin: 0px; padding: 0px; border: none; color: rgb(127, 0, 85); font-weight: bold; background-color: inherit;">default</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;"> {};  </span></span></li><li style="margin: 0px 0px 0px 38px; padding: 0px 0px 0px 10px; border-style: none none none solid; border-left-width: 1px; border-left-color: rgb(209, 215, 220); list-style: decimal-leading-zero outside; color: rgb(92, 92, 92); line-height: 18px; font-size: 1em; background-color: rgb(250, 250, 250);"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;">}  </span></li></ol></div><br style="color: rgb(85, 85, 85); font-family: 'microsoft yahei'; font-size: 15px; line-height: 35px;" /><br style="color: rgb(85, 85, 85); font-family: 'microsoft yahei'; font-size: 15px; line-height: 35px;" /><span style="color: rgb(85, 85, 85); font-family: 'microsoft yahei'; font-size: 15px; line-height: 35px;">其中属性说明: </span><br style="color: rgb(85, 85, 85); font-family: 'microsoft yahei'; font-size: 15px; line-height: 35px;" /><span style="color: rgb(85, 85, 85); font-family: 'microsoft yahei'; font-size: 15px; line-height: 35px;">name属性表示该表主键生成策略的名称,它被引用在@GeneratedValue中设置的“generator”值中。 </span><br style="color: rgb(85, 85, 85); font-family: 'microsoft yahei'; font-size: 15px; line-height: 35px;" /><span style="color: rgb(85, 85, 85); font-family: 'microsoft yahei'; font-size: 15px; line-height: 35px;">table属性表示表生成策略所持久化的表名,例如,这里表使用的是数据库中的“tb_generator”。 </span><br style="color: rgb(85, 85, 85); font-family: 'microsoft yahei'; font-size: 15px; line-height: 35px;" /><span style="color: rgb(85, 85, 85); font-family: 'microsoft yahei'; font-size: 15px; line-height: 35px;">catalog属性和schema具体指定表所在的目录名或是数据库名。 </span><br style="color: rgb(85, 85, 85); font-family: 'microsoft yahei'; font-size: 15px; line-height: 35px;" /><span style="color: rgb(85, 85, 85); font-family: 'microsoft yahei'; font-size: 15px; line-height: 35px;">pkColumnName属性的值表示在持久化表中,该主键生成策略所对应键值的名称。例如在“tb_generator”中将“gen_name”作为主键的键值 </span><br style="color: rgb(85, 85, 85); font-family: 'microsoft yahei'; font-size: 15px; line-height: 35px;" /><span style="color: rgb(85, 85, 85); font-family: 'microsoft yahei'; font-size: 15px; line-height: 35px;">valueColumnName属性的值表示在持久化表中,该主键当前所生成的值,它的值将会随着每次创建累加。例如,在“tb_generator”中将“gen_value”作为主键的值 </span><br style="color: rgb(85, 85, 85); font-family: 'microsoft yahei'; font-size: 15px; line-height: 35px;" /><span style="color: rgb(85, 85, 85); font-family: 'microsoft yahei'; font-size: 15px; line-height: 35px;">pkColumnValue属性的值表示在持久化表中,该生成策略所对应的主键。例如在“tb_generator”表中,将“gen_name”的值为“CUSTOMER_PK”。 </span><br style="color: rgb(85, 85, 85); font-family: 'microsoft yahei'; font-size: 15px; line-height: 35px;" /><span style="color: rgb(85, 85, 85); font-family: 'microsoft yahei'; font-size: 15px; line-height: 35px;">initialValue表示主键初识值,默认为0。 </span><br style="color: rgb(85, 85, 85); font-family: 'microsoft yahei'; font-size: 15px; line-height: 35px;" /><span style="color: rgb(85, 85, 85); font-family: 'microsoft yahei'; font-size: 15px; line-height: 35px;">allocationSize表示每次主键值增加的大小,例如设置成1,则表示每次创建新记录后自动加1,默认为50。 </span><br style="color: rgb(85, 85, 85); font-family: 'microsoft yahei'; font-size: 15px; line-height: 35px;" /><span style="color: rgb(85, 85, 85); font-family: 'microsoft yahei'; font-size: 15px; line-height: 35px;">UniqueConstraint与@Table标记中的用法类似。 </span><br style="color: rgb(85, 85, 85); font-family: 'microsoft yahei'; font-size: 15px; line-height: 35px;" /><br style="color: rgb(85, 85, 85); font-family: 'microsoft yahei'; font-size: 15px; line-height: 35px;" /><span style="color: rgb(85, 85, 85); font-family: 'microsoft yahei'; font-size: 15px; line-height: 35px;">2、SEQUENCE </span><br style="color: rgb(85, 85, 85); font-family: 'microsoft yahei'; font-size: 15px; line-height: 35px;" /><div class="dp-highlighter" id="" style="font-family: Monaco, 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', Consolas, 'Courier New', monospace; width: 659px; overflow: auto; padding: 1px; margin-left: 9px; border-color: rgb(204, 204, 204); color: rgb(85, 85, 85); line-height: 35px; word-break: break-all; word-wrap: break-word; margin-top: 18px !important; margin-right: 0px !important; margin-bottom: 18px !important; background-color: transparent;"><div class="bar" style="padding-left: 45px;"><div class="tools" style="padding: 3px; font-weight: bold; font-stretch: normal; font-size: 9px; line-height: normal; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; color: black; border-left-width: 3px; border-left-style: solid; border-left-color: rgb(108, 226, 108); margin: 0px; background-color: rgb(248, 248, 248);">Java代码  <a target=_blank href="http://xiaogui9317170.iteye.com/blog/283526" title="收藏这段代码" style="text-decoration: none; border: none; padding: 1px; margin: 0px 10px 0px 0px; font-size: 9px; color: rgb(0, 102, 153); display: inline-block; width: 16px; height: 16px; text-indent: -2000px; background-image: none; background-attachment: initial; background-color: inherit; background-size: initial; background-origin: initial; background-clip: initial; background-position: 0% 0%; background-repeat: no-repeat;"><img class="star" src="http://xiaogui9317170.iteye.com/images/icon_star.png" alt="收藏代码" style="border: 0px;" /></a></div></div><ol start="1" class="dp-j" style="margin: 0px 0px 1px; padding: 2px 0px; border: 1px solid rgb(209, 215, 220); list-style-position: initial; list-style-image: initial; color: rgb(43, 145, 175); font-size: 1em; line-height: 1.4em;"><li style="margin: 0px 0px 0px 38px; padding: 0px 0px 0px 10px; border-style: none none none solid; border-left-width: 1px; border-left-color: rgb(209, 215, 220); list-style: decimal-leading-zero outside; color: rgb(92, 92, 92); line-height: 18px; font-size: 1em; background-color: rgb(250, 250, 250);"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;"><span class="annotation" style="margin: 0px; padding: 0px; border: none; color: rgb(100, 100, 100); background-color: inherit;">@Id</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">  </span></span></li><li style="margin: 0px 0px 0px 38px; padding: 0px 0px 0px 10px; border-style: none none none solid; border-left-width: 1px; border-left-color: rgb(209, 215, 220); list-style: decimal-leading-zero outside; color: rgb(92, 92, 92); line-height: 18px; font-size: 1em; background-color: rgb(250, 250, 250);"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;"><span class="annotation" style="margin: 0px; padding: 0px; border: none; color: rgb(100, 100, 100); background-color: inherit;">@GeneratedValue</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">(strategy = GenerationType.SEQUENCE,generator=</span><span class="string" style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit;">"payablemoney_seq"</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">)  </span></span></li><li style="margin: 0px 0px 0px 38px; padding: 0px 0px 0px 10px; border-style: none none none solid; border-left-width: 1px; border-left-color: rgb(209, 215, 220); list-style: decimal-leading-zero outside; color: rgb(92, 92, 92); line-height: 18px; font-size: 1em; background-color: rgb(250, 250, 250);"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;"><span class="annotation" style="margin: 0px; padding: 0px; border: none; color: rgb(100, 100, 100); background-color: inherit;">@SequenceGenerator</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">(name=</span><span class="string" style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit;">"payablemoney_seq"</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">, sequenceName=</span><span class="string" style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit;">"seq_payment"</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">)  </span></span></li></ol></div><br style="color: rgb(85, 85, 85); font-family: 'microsoft yahei'; font-size: 15px; line-height: 35px;" /><span style="color: rgb(85, 85, 85); font-family: 'microsoft yahei'; font-size: 15px; line-height: 35px;">@SequenceGenerator定义 </span><br style="color: rgb(85, 85, 85); font-family: 'microsoft yahei'; font-size: 15px; line-height: 35px;" /><div class="dp-highlighter" id="" style="font-family: Monaco, 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', Consolas, 'Courier New', monospace; width: 659px; overflow: auto; padding: 1px; margin-left: 9px; border-color: rgb(204, 204, 204); color: rgb(85, 85, 85); line-height: 35px; word-break: break-all; word-wrap: break-word; margin-top: 18px !important; margin-right: 0px !important; margin-bottom: 18px !important; background-color: transparent;"><div class="bar" style="padding-left: 45px;"><div class="tools" style="padding: 3px; font-weight: bold; font-stretch: normal; font-size: 9px; line-height: normal; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; color: black; border-left-width: 3px; border-left-style: solid; border-left-color: rgb(108, 226, 108); margin: 0px; background-color: rgb(248, 248, 248);">Java代码  <a target=_blank href="http://xiaogui9317170.iteye.com/blog/283526" title="收藏这段代码" style="text-decoration: none; border: none; padding: 1px; margin: 0px 10px 0px 0px; font-size: 9px; color: rgb(0, 102, 153); display: inline-block; width: 16px; height: 16px; text-indent: -2000px; background-image: none; background-attachment: initial; background-color: inherit; background-size: initial; background-origin: initial; background-clip: initial; background-position: 0% 0%; background-repeat: no-repeat;"><img class="star" src="http://xiaogui9317170.iteye.com/images/icon_star.png" alt="收藏代码" style="border: 0px;" /></a></div></div><ol start="1" class="dp-j" style="margin: 0px 0px 1px; padding: 2px 0px; border: 1px solid rgb(209, 215, 220); list-style-position: initial; list-style-image: initial; color: rgb(43, 145, 175); font-size: 1em; line-height: 1.4em;"><li style="margin: 0px 0px 0px 38px; padding: 0px 0px 0px 10px; border-style: none none none solid; border-left-width: 1px; border-left-color: rgb(209, 215, 220); list-style: decimal-leading-zero outside; color: rgb(92, 92, 92); line-height: 18px; font-size: 1em; background-color: rgb(250, 250, 250);"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;"><span class="annotation" style="margin: 0px; padding: 0px; border: none; color: rgb(100, 100, 100); background-color: inherit;">@Target</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">({TYPE, METHOD, FIELD})   </span></span></li><li style="margin: 0px 0px 0px 38px; padding: 0px 0px 0px 10px; border-style: none none none solid; border-left-width: 1px; border-left-color: rgb(209, 215, 220); list-style: decimal-leading-zero outside; color: rgb(92, 92, 92); line-height: 18px; font-size: 1em; background-color: rgb(250, 250, 250);"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;"><span class="annotation" style="margin: 0px; padding: 0px; border: none; color: rgb(100, 100, 100); background-color: inherit;">@Retention</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">(RUNTIME)  </span></span></li><li style="margin: 0px 0px 0px 38px; padding: 0px 0px 0px 10px; border-style: none none none solid; border-left-width: 1px; border-left-color: rgb(209, 215, 220); list-style: decimal-leading-zero outside; color: rgb(92, 92, 92); line-height: 18px; font-size: 1em; background-color: rgb(250, 250, 250);"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;"><span class="keyword" style="margin: 0px; padding: 0px; border: none; color: rgb(127, 0, 85); font-weight: bold; background-color: inherit;">public</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;"> </span><span class="keyword" style="margin: 0px; padding: 0px; border: none; color: rgb(127, 0, 85); font-weight: bold; background-color: inherit;">@interface</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;"> SequenceGenerator {  </span></span></li><li style="margin: 0px 0px 0px 38px; padding: 0px 0px 0px 10px; border-style: none none none solid; border-left-width: 1px; border-left-color: rgb(209, 215, 220); list-style: decimal-leading-zero outside; color: rgb(92, 92, 92); line-height: 18px; font-size: 1em; background-color: rgb(250, 250, 250);"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;"> String name();  </span></li><li style="margin: 0px 0px 0px 38px; padding: 0px 0px 0px 10px; border-style: none none none solid; border-left-width: 1px; border-left-color: rgb(209, 215, 220); list-style: decimal-leading-zero outside; color: rgb(92, 92, 92); line-height: 18px; font-size: 1em; background-color: rgb(250, 250, 250);"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;"> String sequenceName() <span class="keyword" style="margin: 0px; padding: 0px; border: none; color: rgb(127, 0, 85); font-weight: bold; background-color: inherit;">default</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;"> </span><span class="string" style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit;">""</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">;  </span></span></li><li style="margin: 0px 0px 0px 38px; padding: 0px 0px 0px 10px; border-style: none none none solid; border-left-width: 1px; border-left-color: rgb(209, 215, 220); list-style: decimal-leading-zero outside; color: rgb(92, 92, 92); line-height: 18px; font-size: 1em; background-color: rgb(250, 250, 250);"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;"> <span class="keyword" style="margin: 0px; padding: 0px; border: none; color: rgb(127, 0, 85); font-weight: bold; background-color: inherit;">int</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;"> initialValue() </span><span class="keyword" style="margin: 0px; padding: 0px; border: none; color: rgb(127, 0, 85); font-weight: bold; background-color: inherit;">default</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;"> </span><span class="number" style="margin: 0px; padding: 0px; border: none; color: rgb(192, 0, 0); background-color: inherit;">0</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">;  </span></span></li><li style="margin: 0px 0px 0px 38px; padding: 0px 0px 0px 10px; border-style: none none none solid; border-left-width: 1px; border-left-color: rgb(209, 215, 220); list-style: decimal-leading-zero outside; color: rgb(92, 92, 92); line-height: 18px; font-size: 1em; background-color: rgb(250, 250, 250);"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;"> <span class="keyword" style="margin: 0px; padding: 0px; border: none; color: rgb(127, 0, 85); font-weight: bold; background-color: inherit;">int</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;"> allocationSize() </span><span class="keyword" style="margin: 0px; padding: 0px; border: none; color: rgb(127, 0, 85); font-weight: bold; background-color: inherit;">default</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;"> </span><span class="number" style="margin: 0px; padding: 0px; border: none; color: rgb(192, 0, 0); background-color: inherit;">50</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">;  </span></span></li><li style="margin: 0px 0px 0px 38px; padding: 0px 0px 0px 10px; border-style: none none none solid; border-left-width: 1px; border-left-color: rgb(209, 215, 220); list-style: decimal-leading-zero outside; color: rgb(92, 92, 92); line-height: 18px; font-size: 1em; background-color: rgb(250, 250, 250);"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;">}  </span></li></ol></div><br style="color: rgb(85, 85, 85); font-family: 'microsoft yahei'; font-size: 15px; line-height: 35px;" /><br style="color: rgb(85, 85, 85); font-family: 'microsoft yahei'; font-size: 15px; line-height: 35px;" /><span style="color: rgb(85, 85, 85); font-family: 'microsoft yahei'; font-size: 15px; line-height: 35px;">name属性表示该表主键生成策略的名称,它被引用在@GeneratedValue中设置的“generator”值中。 </span><br style="color: rgb(85, 85, 85); font-family: 'microsoft yahei'; font-size: 15px; line-height: 35px;" /><span style="color: rgb(85, 85, 85); font-family: 'microsoft yahei'; font-size: 15px; line-height: 35px;">sequenceName属性表示生成策略用到的数据库序列名称。 </span><br style="color: rgb(85, 85, 85); font-family: 'microsoft yahei'; font-size: 15px; line-height: 35px;" /><span style="color: rgb(85, 85, 85); font-family: 'microsoft yahei'; font-size: 15px; line-height: 35px;">initialValue表示主键初识值,默认为0。 </span><br style="color: rgb(85, 85, 85); font-family: 'microsoft yahei'; font-size: 15px; line-height: 35px;" /><span style="color: rgb(85, 85, 85); font-family: 'microsoft yahei'; font-size: 15px; line-height: 35px;">allocationSize表示每次主键值增加的大小,例如设置成1,则表示每次创建新记录后自动加1,默认为50。 </span><br style="color: rgb(85, 85, 85); font-family: 'microsoft yahei'; font-size: 15px; line-height: 35px;" /><br style="color: rgb(85, 85, 85); font-family: 'microsoft yahei'; font-size: 15px; line-height: 35px;" /><br style="color: rgb(85, 85, 85); font-family: 'microsoft yahei'; font-size: 15px; line-height: 35px;" /><span style="color: rgb(85, 85, 85); font-family: 'microsoft yahei'; font-size: 15px; line-height: 35px;">3、IDENTITY </span><br style="color: rgb(85, 85, 85); font-family: 'microsoft yahei'; font-size: 15px; line-height: 35px;" /><div class="dp-highlighter" id="" style="font-family: Monaco, 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', Consolas, 'Courier New', monospace; width: 659px; overflow: auto; padding: 1px; margin-left: 9px; border-color: rgb(204, 204, 204); color: rgb(85, 85, 85); line-height: 35px; word-break: break-all; word-wrap: break-word; margin-top: 18px !important; margin-right: 0px !important; margin-bottom: 18px !important; background-color: transparent;"><div class="bar" style="padding-left: 45px;"><div class="tools" style="padding: 3px; font-weight: bold; font-stretch: normal; font-size: 9px; line-height: normal; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; color: black; border-left-width: 3px; border-left-style: solid; border-left-color: rgb(108, 226, 108); margin: 0px; background-color: rgb(248, 248, 248);">Java代码  <a target=_blank href="http://xiaogui9317170.iteye.com/blog/283526" title="收藏这段代码" style="text-decoration: none; border: none; padding: 1px; margin: 0px 10px 0px 0px; font-size: 9px; color: rgb(0, 102, 153); display: inline-block; width: 16px; height: 16px; text-indent: -2000px; background-image: none; background-attachment: initial; background-color: inherit; background-size: initial; background-origin: initial; background-clip: initial; background-position: 0% 0%; background-repeat: no-repeat;"><img class="star" src="http://xiaogui9317170.iteye.com/images/icon_star.png" alt="收藏代码" style="border: 0px;" /></a></div></div><ol start="1" class="dp-j" style="margin: 0px 0px 1px; padding: 2px 0px; border: 1px solid rgb(209, 215, 220); list-style-position: initial; list-style-image: initial; color: rgb(43, 145, 175); font-size: 1em; line-height: 1.4em;"><li style="margin: 0px 0px 0px 38px; padding: 0px 0px 0px 10px; border-style: none none none solid; border-left-width: 1px; border-left-color: rgb(209, 215, 220); list-style: decimal-leading-zero outside; color: rgb(92, 92, 92); line-height: 18px; font-size: 1em; background-color: rgb(250, 250, 250);"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;"><span class="annotation" style="margin: 0px; padding: 0px; border: none; color: rgb(100, 100, 100); background-color: inherit;">@Id</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">  </span></span></li><li style="margin: 0px 0px 0px 38px; padding: 0px 0px 0px 10px; border-style: none none none solid; border-left-width: 1px; border-left-color: rgb(209, 215, 220); list-style: decimal-leading-zero outside; color: rgb(92, 92, 92); line-height: 18px; font-size: 1em; background-color: rgb(250, 250, 250);"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;"><span class="annotation" style="margin: 0px; padding: 0px; border: none; color: rgb(100, 100, 100); background-color: inherit;">@GeneratedValue</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">(strategy = GenerationType.IDENTITY)  </span></span></li></ol></div><br style="color: rgb(85, 85, 85); font-family: 'microsoft yahei'; font-size: 15px; line-height: 35px;" /><span style="color: rgb(85, 85, 85); font-family: 'microsoft yahei'; font-size: 15px; line-height: 35px;">4、AUTO </span><br style="color: rgb(85, 85, 85); font-family: 'microsoft yahei'; font-size: 15px; line-height: 35px;" /><div class="dp-highlighter" id="" style="font-family: Monaco, 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', Consolas, 'Courier New', monospace; width: 659px; overflow: auto; padding: 1px; margin-left: 9px; border-color: rgb(204, 204, 204); color: rgb(85, 85, 85); line-height: 35px; word-break: break-all; word-wrap: break-word; margin-top: 18px !important; margin-right: 0px !important; margin-bottom: 18px !important; background-color: transparent;"><div class="bar" style="padding-left: 45px;"><div class="tools" style="padding: 3px; font-weight: bold; font-stretch: normal; font-size: 9px; line-height: normal; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; color: black; border-left-width: 3px; border-left-style: solid; border-left-color: rgb(108, 226, 108); margin: 0px; background-color: rgb(248, 248, 248);">Java代码  <a target=_blank href="http://xiaogui9317170.iteye.com/blog/283526" title="收藏这段代码" style="text-decoration: none; border: none; padding: 1px; margin: 0px 10px 0px 0px; font-size: 9px; color: rgb(0, 102, 153); display: inline-block; width: 16px; height: 16px; text-indent: -2000px; background-image: none; background-attachment: initial; background-color: inherit; background-size: initial; background-origin: initial; background-clip: initial; background-position: 0% 0%; background-repeat: no-repeat;"><img class="star" src="http://xiaogui9317170.iteye.com/images/icon_star.png" alt="收藏代码" style="border: 0px;" /></a></div></div><ol start="1" class="dp-j" style="margin: 0px 0px 1px; padding: 2px 0px; border: 1px solid rgb(209, 215, 220); list-style-position: initial; list-style-image: initial; color: rgb(43, 145, 175); font-size: 1em; line-height: 1.4em;"><li style="margin: 0px 0px 0px 38px; padding: 0px 0px 0px 10px; border-style: none none none solid; border-left-width: 1px; border-left-color: rgb(209, 215, 220); list-style: decimal-leading-zero outside; color: rgb(92, 92, 92); line-height: 18px; font-size: 1em; background-color: rgb(250, 250, 250);"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;"><span class="annotation" style="margin: 0px; padding: 0px; border: none; color: rgb(100, 100, 100); background-color: inherit;">@Id</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">  </span></span></li><li style="margin: 0px 0px 0px 38px; padding: 0px 0px 0px 10px; border-style: none none none solid; border-left-width: 1px; border-left-color: rgb(209, 215, 220); list-style: decimal-leading-zero outside; color: rgb(92, 92, 92); line-height: 18px; font-size: 1em; background-color: rgb(250, 250, 250);"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;"><span class="annotation" style="margin: 0px; padding: 0px; border: none; color: rgb(100, 100, 100); background-color: inherit;">@GeneratedValue</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">(strategy = GenerationType.AUTO)  </span></span></li></ol></div><br style="color: rgb(85, 85, 85); font-family: 'microsoft yahei'; font-size: 15px; line-height: 35px;" /><span style="color: rgb(85, 85, 85); font-family: 'microsoft yahei'; font-size: 15px; line-height: 35px;">在指定主键时,如果不指定主键生成策略,默认为AUTO。 </span><br style="color: rgb(85, 85, 85); font-family: 'microsoft yahei'; font-size: 15px; line-height: 35px;" /><div class="dp-highlighter" id="" style="font-family: Monaco, 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', Consolas, 'Courier New', monospace; width: 659px; overflow: auto; padding: 1px; margin-left: 9px; border-color: rgb(204, 204, 204); color: rgb(85, 85, 85); line-height: 35px; word-break: break-all; word-wrap: break-word; margin-top: 18px !important; margin-right: 0px !important; margin-bottom: 18px !important; background-color: transparent;"><div class="bar" style="padding-left: 45px;"><div class="tools" style="padding: 3px; font-weight: bold; font-stretch: normal; font-size: 9px; line-height: normal; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; color: black; border-left-width: 3px; border-left-style: solid; border-left-color: rgb(108, 226, 108); margin: 0px; background-color: rgb(248, 248, 248);">Java代码  <a target=_blank href="http://xiaogui9317170.iteye.com/blog/283526" title="收藏这段代码" style="text-decoration: none; border: none; padding: 1px; margin: 0px 10px 0px 0px; font-size: 9px; color: rgb(0, 102, 153); display: inline-block; width: 16px; height: 16px; text-indent: -2000px; background-image: none; background-attachment: initial; background-color: inherit; background-size: initial; background-origin: initial; background-clip: initial; background-position: 0% 0%; background-repeat: no-repeat;"><img class="star" src="http://xiaogui9317170.iteye.com/images/icon_star.png" alt="收藏代码" style="border: 0px;" /></a></div></div><ol start="1" class="dp-j" style="margin: 0px 0px 1px; padding: 2px 0px; border: 1px solid rgb(209, 215, 220); list-style-position: initial; list-style-image: initial; color: rgb(43, 145, 175); font-size: 1em; line-height: 1.4em;"><li style="margin: 0px 0px 0px 38px; padding: 0px 0px 0px 10px; border-style: none none none solid; border-left-width: 1px; border-left-color: rgb(209, 215, 220); list-style: decimal-leading-zero outside; color: rgb(92, 92, 92); line-height: 18px; font-size: 1em; background-color: rgb(250, 250, 250);"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;"><span class="annotation" style="margin: 0px; padding: 0px; border: none; color: rgb(100, 100, 100); background-color: inherit;">@Id</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">  </span></span></li></ol></div><br style="color: rgb(85, 85, 85); font-family: 'microsoft yahei'; font-size: 15px; line-height: 35px;" /><br style="color: rgb(85, 85, 85); font-family: 'microsoft yahei'; font-size: 15px; line-height: 35px;" /><span style="color: rgb(85, 85, 85); font-family: 'microsoft yahei'; font-size: 15px; line-height: 35px;">跟下面的定义是一样的。 </span><br style="color: rgb(85, 85, 85); font-family: 'microsoft yahei'; font-size: 15px; line-height: 35px;" /><div class="dp-highlighter" id="" style="font-family: Monaco, 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', Consolas, 'Courier New', monospace; width: 659px; overflow: auto; padding: 1px; margin-left: 9px; border-color: rgb(204, 204, 204); color: rgb(85, 85, 85); line-height: 35px; word-break: break-all; word-wrap: break-word; margin-top: 18px !important; margin-right: 0px !important; margin-bottom: 18px !important; background-color: transparent;"><div class="bar" style="padding-left: 45px;"><div class="tools" style="padding: 3px; font-weight: bold; font-stretch: normal; font-size: 9px; line-height: normal; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; color: black; border-left-width: 3px; border-left-style: solid; border-left-color: rgb(108, 226, 108); margin: 0px; background-color: rgb(248, 248, 248);">Java代码  <a target=_blank href="http://xiaogui9317170.iteye.com/blog/283526" title="收藏这段代码" style="text-decoration: none; border: none; padding: 1px; margin: 0px 10px 0px 0px; font-size: 9px; color: rgb(0, 102, 153); display: inline-block; width: 16px; height: 16px; text-indent: -2000px; background-image: none; background-attachment: initial; background-color: inherit; background-size: initial; background-origin: initial; background-clip: initial; background-position: 0% 0%; background-repeat: no-repeat;"><img class="star" src="http://xiaogui9317170.iteye.com/images/icon_star.png" alt="收藏代码" style="border: 0px;" /></a></div></div><ol start="1" class="dp-j" style="margin: 0px 0px 1px; padding: 2px 0px; border: 1px solid rgb(209, 215, 220); list-style-position: initial; list-style-image: initial; color: rgb(43, 145, 175); font-size: 1em; line-height: 1.4em;"><li style="margin: 0px 0px 0px 38px; padding: 0px 0px 0px 10px; border-style: none none none solid; border-left-width: 1px; border-left-color: rgb(209, 215, 220); list-style: decimal-leading-zero outside; color: rgb(92, 92, 92); line-height: 18px; font-size: 1em; background-color: rgb(250, 250, 250);"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;"><span class="annotation" style="margin: 0px; padding: 0px; border: none; color: rgb(100, 100, 100); background-color: inherit;">@Id</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">  </span></span></li><li style="margin: 0px 0px 0px 38px; padding: 0px 0px 0px 10px; border-style: none none none solid; border-left-width: 1px; border-left-color: rgb(209, 215, 220); list-style: decimal-leading-zero outside; color: rgb(92, 92, 92); line-height: 18px; font-size: 1em; background-color: rgb(250, 250, 250);"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;"><span class="annotation" style="margin: 0px; padding: 0px; border: none; color: rgb(100, 100, 100); background-color: inherit;">@GeneratedValue</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">(strategy = GenerationType.AUTO)  </span></span></li></ol></div><br style="color: rgb(85, 85, 85); font-family: 'microsoft yahei'; font-size: 15px; line-height: 35px;" /><span style="color: rgb(85, 85, 85); font-family: 'microsoft yahei'; font-size: 15px; line-height: 35px;">二、hibernate主键策略生成器 </span><br style="color: rgb(85, 85, 85); font-family: 'microsoft yahei'; font-size: 15px; line-height: 35px;" /><span style="color: rgb(85, 85, 85); font-family: 'microsoft yahei'; font-size: 15px; line-height: 35px;">hibernate提供多种主键生成策略,有点是类似于JPA,有的是hibernate特有: </span><br style="color: rgb(85, 85, 85); font-family: 'microsoft yahei'; font-size: 15px; line-height: 35px;" /><span style="color: rgb(85, 85, 85); font-family: 'microsoft yahei'; font-size: 15px; line-height: 35px;">native: 对于 oracle 采用 Sequence 方式,对于MySQL 和 SQL Server 采用identity(自增主键生成机制),native就是将主键的生成工作交由数据库完成,hibernate不管(很常用)。 </span><br style="color: rgb(85, 85, 85); font-family: 'microsoft yahei'; font-size: 15px; line-height: 35px;" /><span style="color: rgb(85, 85, 85); font-family: 'microsoft yahei'; font-size: 15px; line-height: 35px;">uuid: 采用128位的uuid算法生成主键,uuid被编码为一个32位16进制数字的字符串。占用空间大(字符串类型)。 </span><br style="color: rgb(85, 85, 85); font-family: 'microsoft yahei'; font-size: 15px; line-height: 35px;" /><span style="color: rgb(85, 85, 85); font-family: 'microsoft yahei'; font-size: 15px; line-height: 35px;">hilo: 使用hilo生成策略,要在数据库中建立一张额外的表,默认表名为hibernate_unique_key,默认字段为integer类型,名称是next_hi(比较少用)。 </span><br style="color: rgb(85, 85, 85); font-family: 'microsoft yahei'; font-size: 15px; line-height: 35px;" /><span style="color: rgb(85, 85, 85); font-family: 'microsoft yahei'; font-size: 15px; line-height: 35px;">assigned: 在插入数据的时候主键由程序处理(很常用),这是 <generator>元素没有指定时的默认生成策略。等同于JPA中的AUTO。 </span><br style="color: rgb(85, 85, 85); font-family: 'microsoft yahei'; font-size: 15px; line-height: 35px;" /><span style="color: rgb(85, 85, 85); font-family: 'microsoft yahei'; font-size: 15px; line-height: 35px;">identity: 使用SQL Server 和 MySQL 的自增字段,这个方法不能放到 Oracle 中,Oracle 不支持自增字段,要设定sequence(MySQL 和 SQL Server 中很常用)。 </span><br style="color: rgb(85, 85, 85); font-family: 'microsoft yahei'; font-size: 15px; line-height: 35px;" /><span style="color: rgb(85, 85, 85); font-family: 'microsoft yahei'; font-size: 15px; line-height: 35px;">          等同于JPA中的INDENTITY。 </span><br style="color: rgb(85, 85, 85); font-family: 'microsoft yahei'; font-size: 15px; line-height: 35px;" /><span style="color: rgb(85, 85, 85); font-family: 'microsoft yahei'; font-size: 15px; line-height: 35px;">select: 使用触发器生成主键(主要用于早期的数据库主键生成机制,少用)。 </span><br style="color: rgb(85, 85, 85); font-family: 'microsoft yahei'; font-size: 15px; line-height: 35px;" /><span style="color: rgb(85, 85, 85); font-family: 'microsoft yahei'; font-size: 15px; line-height: 35px;">sequence: 调用底层数据库的序列来生成主键,要设定序列名,不然hibernate无法找到。 </span><br style="color: rgb(85, 85, 85); font-family: 'microsoft yahei'; font-size: 15px; line-height: 35px;" /><span style="color: rgb(85, 85, 85); font-family: 'microsoft yahei'; font-size: 15px; line-height: 35px;">seqhilo: 通过hilo算法实现,但是主键历史保存在Sequence中,适用于支持 Sequence 的数据库,如 Oracle(比较少用) </span><br style="color: rgb(85, 85, 85); font-family: 'microsoft yahei'; font-size: 15px; line-height: 35px;" /><span style="color: rgb(85, 85, 85); font-family: 'microsoft yahei'; font-size: 15px; line-height: 35px;">increment: 插入数据的时候hibernate会给主键添加一个自增的主键,但是一个hibernate实例就维护一个计数器,所以在多个实例运行的时候不能使用这个方法。 </span><br style="color: rgb(85, 85, 85); font-family: 'microsoft yahei'; font-size: 15px; line-height: 35px;" /><span style="color: rgb(85, 85, 85); font-family: 'microsoft yahei'; font-size: 15px; line-height: 35px;">foreign: 使用另外一个相关联的对象的主键。通常和<one-to-one>联合起来使用。 </span><br style="color: rgb(85, 85, 85); font-family: 'microsoft yahei'; font-size: 15px; line-height: 35px;" /><span style="color: rgb(85, 85, 85); font-family: 'microsoft yahei'; font-size: 15px; line-height: 35px;">guid: 采用数据库底层的guid算法机制,对应MYSQL的uuid()函数,SQL Server的newid()函数,ORACLE的rawtohex(sys_guid())函数等。 </span><br style="color: rgb(85, 85, 85); font-family: 'microsoft yahei'; font-size: 15px; line-height: 35px;" /><span style="color: rgb(85, 85, 85); font-family: 'microsoft yahei'; font-size: 15px; line-height: 35px;">uuid.hex: 看uuid,建议用uuid替换。 </span><br style="color: rgb(85, 85, 85); font-family: 'microsoft yahei'; font-size: 15px; line-height: 35px;" /><span style="color: rgb(85, 85, 85); font-family: 'microsoft yahei'; font-size: 15px; line-height: 35px;">sequence-identity: sequence策略的扩展,采用立即检索策略来获取sequence值,需要JDBC3.0和JDK4以上(含1.4)版本 </span><br style="color: rgb(85, 85, 85); font-family: 'microsoft yahei'; font-size: 15px; line-height: 35px;" /><br style="color: rgb(85, 85, 85); font-family: 'microsoft yahei'; font-size: 15px; line-height: 35px;" /><span style="color: rgb(85, 85, 85); font-family: 'microsoft yahei'; font-size: 15px; line-height: 35px;">hibernate提供了多种生成器供选择,基于Annotation的方式通过@GenericGenerator实现. </span><br style="color: rgb(85, 85, 85); font-family: 'microsoft yahei'; font-size: 15px; line-height: 35px;" /><span style="color: rgb(85, 85, 85); font-family: 'microsoft yahei'; font-size: 15px; line-height: 35px;">hibernate每种主键生成策略提供接口org.hibernate.id.IdentifierGenerator的实现类,如果要实现自定义的主键生成策略也必须实现此接口. </span><br style="color: rgb(85, 85, 85); font-family: 'microsoft yahei'; font-size: 15px; line-height: 35px;" /><br style="color: rgb(85, 85, 85); font-family: 'microsoft yahei'; font-size: 15px; line-height: 35px;" /><div class="dp-highlighter" id="" style="font-family: Monaco, 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', Consolas, 'Courier New', monospace; width: 659px; overflow: auto; padding: 1px; margin-left: 9px; border-color: rgb(204, 204, 204); color: rgb(85, 85, 85); line-height: 35px; word-break: break-all; word-wrap: break-word; margin-top: 18px !important; margin-right: 0px !important; margin-bottom: 18px !important; background-color: transparent;"><div class="bar" style="padding-left: 45px;"><div class="tools" style="padding: 3px; font-weight: bold; font-stretch: normal; font-size: 9px; line-height: normal; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; color: black; border-left-width: 3px; border-left-style: solid; border-left-color: rgb(108, 226, 108); margin: 0px; background-color: rgb(248, 248, 248);">Java代码  <a target=_blank href="http://xiaogui9317170.iteye.com/blog/283526" title="收藏这段代码" style="text-decoration: none; border: none; padding: 1px; margin: 0px 10px 0px 0px; font-size: 9px; color: rgb(0, 102, 153); display: inline-block; width: 16px; height: 16px; text-indent: -2000px; background-image: none; background-attachment: initial; background-color: inherit; background-size: initial; background-origin: initial; background-clip: initial; background-position: 0% 0%; background-repeat: no-repeat;"><img class="star" src="http://xiaogui9317170.iteye.com/images/icon_star.png" alt="收藏代码" style="border: 0px;" /></a></div></div><ol start="1" class="dp-j" style="margin: 0px 0px 1px; padding: 2px 0px; border: 1px solid rgb(209, 215, 220); list-style-position: initial; list-style-image: initial; color: rgb(43, 145, 175); font-size: 1em; line-height: 1.4em;"><li style="margin: 0px 0px 0px 38px; padding: 0px 0px 0px 10px; border-style: none none none solid; border-left-width: 1px; border-left-color: rgb(209, 215, 220); list-style: decimal-leading-zero outside; color: rgb(92, 92, 92); line-height: 18px; font-size: 1em; background-color: rgb(250, 250, 250);"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;"><span class="keyword" style="margin: 0px; padding: 0px; border: none; color: rgb(127, 0, 85); font-weight: bold; background-color: inherit;">public</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;"> </span><span class="keyword" style="margin: 0px; padding: 0px; border: none; color: rgb(127, 0, 85); font-weight: bold; background-color: inherit;">interface</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;"> IdentifierGenerator {  </span></span></li><li style="margin: 0px 0px 0px 38px; padding: 0px 0px 0px 10px; border-style: none none none solid; border-left-width: 1px; border-left-color: rgb(209, 215, 220); list-style: decimal-leading-zero outside; color: rgb(92, 92, 92); line-height: 18px; font-size: 1em; background-color: rgb(250, 250, 250);"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;">    <span class="comment" style="margin: 0px; padding: 0px; border: none; color: rgb(0, 130, 0); background-color: inherit;">/**</span> </span></li><li style="margin: 0px 0px 0px 38px; padding: 0px 0px 0px 10px; border-style: none none none solid; border-left-width: 1px; border-left-color: rgb(209, 215, 220); list-style: decimal-leading-zero outside; color: rgb(92, 92, 92); line-height: 18px; font-size: 1em; background-color: rgb(250, 250, 250);"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;"><span class="comment" style="margin: 0px; padding: 0px; border: none; color: rgb(0, 130, 0); background-color: inherit;">     * The configuration parameter holding the entity name</span> </span></li><li style="margin: 0px 0px 0px 38px; padding: 0px 0px 0px 10px; border-style: none none none solid; border-left-width: 1px; border-left-color: rgb(209, 215, 220); list-style: decimal-leading-zero outside; color: rgb(92, 92, 92); line-height: 18px; font-size: 1em; background-color: rgb(250, 250, 250);"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;"><span class="comment" style="margin: 0px; padding: 0px; border: none; color: rgb(0, 130, 0); background-color: inherit;">     */</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">  </span></span></li><li style="margin: 0px 0px 0px 38px; padding: 0px 0px 0px 10px; border-style: none none none solid; border-left-width: 1px; border-left-color: rgb(209, 215, 220); list-style: decimal-leading-zero outside; color: rgb(92, 92, 92); line-height: 18px; font-size: 1em; background-color: rgb(250, 250, 250);"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;">    <span class="keyword" style="margin: 0px; padding: 0px; border: none; color: rgb(127, 0, 85); font-weight: bold; background-color: inherit;">public</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;"> </span><span class="keyword" style="margin: 0px; padding: 0px; border: none; color: rgb(127, 0, 85); font-weight: bold; background-color: inherit;">static</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;"> </span><span class="keyword" style="margin: 0px; padding: 0px; border: none; color: rgb(127, 0, 85); font-weight: bold; background-color: inherit;">final</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;"> String ENTITY_NAME = </span><span class="string" style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit;">"entity_name"</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">;  </span></span></li><li style="margin: 0px 0px 0px 38px; padding: 0px 0px 0px 10px; border-style: none none none solid; border-left-width: 1px; border-left-color: rgb(209, 215, 220); list-style: decimal-leading-zero outside; color: rgb(92, 92, 92); line-height: 18px; font-size: 1em; background-color: rgb(250, 250, 250);"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;">      </span></li><li style="margin: 0px 0px 0px 38px; padding: 0px 0px 0px 10px; border-style: none none none solid; border-left-width: 1px; border-left-color: rgb(209, 215, 220); list-style: decimal-leading-zero outside; color: rgb(92, 92, 92); line-height: 18px; font-size: 1em; background-color: rgb(250, 250, 250);"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;">  <span class="comment" style="margin: 0px; padding: 0px; border: none; color: rgb(0, 130, 0); background-color: inherit;">/**</span> </span></li><li style="margin: 0px 0px 0px 38px; padding: 0px 0px 0px 10px; border-style: none none none solid; border-left-width: 1px; border-left-color: rgb(209, 215, 220); list-style: decimal-leading-zero outside; color: rgb(92, 92, 92); line-height: 18px; font-size: 1em; background-color: rgb(250, 250, 250);"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;"><span class="comment" style="margin: 0px; padding: 0px; border: none; color: rgb(0, 130, 0); background-color: inherit;">   * Generate a new identifier.</span> </span></li><li style="margin: 0px 0px 0px 38px; padding: 0px 0px 0px 10px; border-style: none none none solid; border-left-width: 1px; border-left-color: rgb(209, 215, 220); list-style: decimal-leading-zero outside; color: rgb(92, 92, 92); line-height: 18px; font-size: 1em; background-color: rgb(250, 250, 250);"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;"><span class="comment" style="margin: 0px; padding: 0px; border: none; color: rgb(0, 130, 0); background-color: inherit;">   * @param session</span> </span></li><li style="margin: 0px 0px 0px 38px; padding: 0px 0px 0px 10px; border-style: none none none solid; border-left-width: 1px; border-left-color: rgb(209, 215, 220); list-style: decimal-leading-zero outside; color: rgb(92, 92, 92); line-height: 18px; font-size: 1em; background-color: rgb(250, 250, 250);"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;"><span class="comment" style="margin: 0px; padding: 0px; border: none; color: rgb(0, 130, 0); background-color: inherit;">   * @param object the entity or toplevel collection for which the id is being generated</span> </span></li><li style="margin: 0px 0px 0px 38px; padding: 0px 0px 0px 10px; border-style: none none none solid; border-left-width: 1px; border-left-color: rgb(209, 215, 220); list-style: decimal-leading-zero outside; color: rgb(92, 92, 92); line-height: 18px; font-size: 1em; background-color: rgb(250, 250, 250);"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;"><span class="comment" style="margin: 0px; padding: 0px; border: none; color: rgb(0, 130, 0); background-color: inherit;">   *</span> </span></li><li style="margin: 0px 0px 0px 38px; padding: 0px 0px 0px 10px; border-style: none none none solid; border-left-width: 1px; border-left-color: rgb(209, 215, 220); list-style: decimal-leading-zero outside; color: rgb(92, 92, 92); line-height: 18px; font-size: 1em; background-color: rgb(250, 250, 250);"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;"><span class="comment" style="margin: 0px; padding: 0px; border: none; color: rgb(0, 130, 0); background-color: inherit;">   * @return a new identifier</span> </span></li><li style="margin: 0px 0px 0px 38px; padding: 0px 0px 0px 10px; border-style: none none none solid; border-left-width: 1px; border-left-color: rgb(209, 215, 220); list-style: decimal-leading-zero outside; color: rgb(92, 92, 92); line-height: 18px; font-size: 1em; background-color: rgb(250, 250, 250);"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;"><span class="comment" style="margin: 0px; padding: 0px; border: none; color: rgb(0, 130, 0); background-color: inherit;">   * @throws HibernateException</span> </span></li><li style="margin: 0px 0px 0px 38px; padding: 0px 0px 0px 10px; border-style: none none none solid; border-left-width: 1px; border-left-color: rgb(209, 215, 220); list-style: decimal-leading-zero outside; color: rgb(92, 92, 92); line-height: 18px; font-size: 1em; background-color: rgb(250, 250, 250);"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;"><span class="comment" style="margin: 0px; padding: 0px; border: none; color: rgb(0, 130, 0); background-color: inherit;">   */</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">  </span></span></li><li style="margin: 0px 0px 0px 38px; padding: 0px 0px 0px 10px; border-style: none none none solid; border-left-width: 1px; border-left-color: rgb(209, 215, 220); list-style: decimal-leading-zero outside; color: rgb(92, 92, 92); line-height: 18px; font-size: 1em; background-color: rgb(250, 250, 250);"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;">  <span class="keyword" style="margin: 0px; padding: 0px; border: none; color: rgb(127, 0, 85); font-weight: bold; background-color: inherit;">public</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;"> Serializable generate(SessionImplementor session, Object object)   </span></span></li><li style="margin: 0px 0px 0px 38px; padding: 0px 0px 0px 10px; border-style: none none none solid; border-left-width: 1px; border-left-color: rgb(209, 215, 220); list-style: decimal-leading-zero outside; color: rgb(92, 92, 92); line-height: 18px; font-size: 1em; background-color: rgb(250, 250, 250);"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;">    <span class="keyword" style="margin: 0px; padding: 0px; border: none; color: rgb(127, 0, 85); font-weight: bold; background-color: inherit;">throws</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;"> HibernateException;  </span></span></li><li style="margin: 0px 0px 0px 38px; padding: 0px 0px 0px 10px; border-style: none none none solid; border-left-width: 1px; border-left-color: rgb(209, 215, 220); list-style: decimal-leading-zero outside; color: rgb(92, 92, 92); line-height: 18px; font-size: 1em; background-color: rgb(250, 250, 250);"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;">}  </span></li></ol></div><br style="color: rgb(85, 85, 85); font-family: 'microsoft yahei'; font-size: 15px; line-height: 35px;" /><br style="color: rgb(85, 85, 85); font-family: 'microsoft yahei'; font-size: 15px; line-height: 35px;" /><span style="color: rgb(85, 85, 85); font-family: 'microsoft yahei'; font-size: 15px; line-height: 35px;">IdentifierGenerator提供一generate方法,generate方法返回产生的主键. </span><br style="color: rgb(85, 85, 85); font-family: 'microsoft yahei'; font-size: 15px; line-height: 35px;" /><br style="color: rgb(85, 85, 85); font-family: 'microsoft yahei'; font-size: 15px; line-height: 35px;" /><br style="color: rgb(85, 85, 85); font-family: 'microsoft yahei'; font-size: 15px; line-height: 35px;" /><span style="color: rgb(85, 85, 85); font-family: 'microsoft yahei'; font-size: 15px; line-height: 35px;">三、@GenericGenerator </span><br style="color: rgb(85, 85, 85); font-family: 'microsoft yahei'; font-size: 15px; line-height: 35px;" /><span style="color: rgb(85, 85, 85); font-family: 'microsoft yahei'; font-size: 15px; line-height: 35px;">自定义主键生成策略,由@GenericGenerator实现。 </span><br style="color: rgb(85, 85, 85); font-family: 'microsoft yahei'; font-size: 15px; line-height: 35px;" /><span style="color: rgb(85, 85, 85); font-family: 'microsoft yahei'; font-size: 15px; line-height: 35px;">hibernate在JPA的基础上进行了扩展,可以用一下方式引入hibernate独有的主键生成策略,就是通过@GenericGenerator加入的。 </span><br style="color: rgb(85, 85, 85); font-family: 'microsoft yahei'; font-size: 15px; line-height: 35px;" /><br style="color: rgb(85, 85, 85); font-family: 'microsoft yahei'; font-size: 15px; line-height: 35px;" /><span style="color: rgb(85, 85, 85); font-family: 'microsoft yahei'; font-size: 15px; line-height: 35px;">比如说,JPA标准用法 </span><br style="color: rgb(85, 85, 85); font-family: 'microsoft yahei'; font-size: 15px; line-height: 35px;" /><div class="dp-highlighter" id="" style="font-family: Monaco, 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', Consolas, 'Courier New', monospace; width: 659px; overflow: auto; padding: 1px; margin-left: 9px; border-color: rgb(204, 204, 204); color: rgb(85, 85, 85); line-height: 35px; word-break: break-all; word-wrap: break-word; margin-top: 18px !important; margin-right: 0px !important; margin-bottom: 18px !important; background-color: transparent;"><div class="bar" style="padding-left: 45px;"><div class="tools" style="padding: 3px; font-weight: bold; font-stretch: normal; font-size: 9px; line-height: normal; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; color: black; border-left-width: 3px; border-left-style: solid; border-left-color: rgb(108, 226, 108); margin: 0px; background-color: rgb(248, 248, 248);">Java代码  <a target=_blank href="http://xiaogui9317170.iteye.com/blog/283526" title="收藏这段代码" style="text-decoration: none; border: none; padding: 1px; margin: 0px 10px 0px 0px; font-size: 9px; color: rgb(0, 102, 153); display: inline-block; width: 16px; height: 16px; text-indent: -2000px; background-image: none; background-attachment: initial; background-color: inherit; background-size: initial; background-origin: initial; background-clip: initial; background-position: 0% 0%; background-repeat: no-repeat;"><img class="star" src="http://xiaogui9317170.iteye.com/images/icon_star.png" alt="收藏代码" style="border: 0px;" /></a></div></div><ol start="1" class="dp-j" style="margin: 0px 0px 1px; padding: 2px 0px; border: 1px solid rgb(209, 215, 220); list-style-position: initial; list-style-image: initial; color: rgb(43, 145, 175); font-size: 1em; line-height: 1.4em;"><li style="margin: 0px 0px 0px 38px; padding: 0px 0px 0px 10px; border-style: none none none solid; border-left-width: 1px; border-left-color: rgb(209, 215, 220); list-style: decimal-leading-zero outside; color: rgb(92, 92, 92); line-height: 18px; font-size: 1em; background-color: rgb(250, 250, 250);"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;"><span class="annotation" style="margin: 0px; padding: 0px; border: none; color: rgb(100, 100, 100); background-color: inherit;">@Id</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">  </span></span></li><li style="margin: 0px 0px 0px 38px; padding: 0px 0px 0px 10px; border-style: none none none solid; border-left-width: 1px; border-left-color: rgb(209, 215, 220); list-style: decimal-leading-zero outside; color: rgb(92, 92, 92); line-height: 18px; font-size: 1em; background-color: rgb(250, 250, 250);"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;"><span class="annotation" style="margin: 0px; padding: 0px; border: none; color: rgb(100, 100, 100); background-color: inherit;">@GeneratedValue</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">(GenerationType.AUTO)  </span></span></li></ol></div><br style="color: rgb(85, 85, 85); font-family: 'microsoft yahei'; font-size: 15px; line-height: 35px;" /><span style="color: rgb(85, 85, 85); font-family: 'microsoft yahei'; font-size: 15px; line-height: 35px;">就可以用hibernate特有以下用法来实现 </span><br style="color: rgb(85, 85, 85); font-family: 'microsoft yahei'; font-size: 15px; line-height: 35px;" /><div class="dp-highlighter" id="" style="font-family: Monaco, 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', Consolas, 'Courier New', monospace; width: 659px; overflow: auto; padding: 1px; margin-left: 9px; border-color: rgb(204, 204, 204); color: rgb(85, 85, 85); line-height: 35px; word-break: break-all; word-wrap: break-word; margin-top: 18px !important; margin-right: 0px !important; margin-bottom: 18px !important; background-color: transparent;"><div class="bar" style="padding-left: 45px;"><div class="tools" style="padding: 3px; font-weight: bold; font-stretch: normal; font-size: 9px; line-height: normal; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; color: black; border-left-width: 3px; border-left-style: solid; border-left-color: rgb(108, 226, 108); margin: 0px; background-color: rgb(248, 248, 248);">Java代码  <a target=_blank href="http://xiaogui9317170.iteye.com/blog/283526" title="收藏这段代码" style="text-decoration: none; border: none; padding: 1px; margin: 0px 10px 0px 0px; font-size: 9px; color: rgb(0, 102, 153); display: inline-block; width: 16px; height: 16px; text-indent: -2000px; background-image: none; background-attachment: initial; background-color: inherit; background-size: initial; background-origin: initial; background-clip: initial; background-position: 0% 0%; background-repeat: no-repeat;"><img class="star" src="http://xiaogui9317170.iteye.com/images/icon_star.png" alt="收藏代码" style="border: 0px;" /></a></div></div><ol start="1" class="dp-j" style="margin: 0px 0px 1px; padding: 2px 0px; border: 1px solid rgb(209, 215, 220); list-style-position: initial; list-style-image: initial; color: rgb(43, 145, 175); font-size: 1em; line-height: 1.4em;"><li style="margin: 0px 0px 0px 38px; padding: 0px 0px 0px 10px; border-style: none none none solid; border-left-width: 1px; border-left-color: rgb(209, 215, 220); list-style: decimal-leading-zero outside; color: rgb(92, 92, 92); line-height: 18px; font-size: 1em; background-color: rgb(250, 250, 250);"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;"><span class="annotation" style="margin: 0px; padding: 0px; border: none; color: rgb(100, 100, 100); background-color: inherit;">@GeneratedValue</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">(generator = </span><span class="string" style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit;">"paymentableGenerator"</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">)    </span></span></li><li style="margin: 0px 0px 0px 38px; padding: 0px 0px 0px 10px; border-style: none none none solid; border-left-width: 1px; border-left-color: rgb(209, 215, 220); list-style: decimal-leading-zero outside; color: rgb(92, 92, 92); line-height: 18px; font-size: 1em; background-color: rgb(250, 250, 250);"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;"><span class="annotation" style="margin: 0px; padding: 0px; border: none; color: rgb(100, 100, 100); background-color: inherit;">@GenericGenerator</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">(name = </span><span class="string" style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit;">"paymentableGenerator"</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">, strategy = </span><span class="string" style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit;">"assigned"</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">)  </span></span></li></ol></div><br style="color: rgb(85, 85, 85); font-family: 'microsoft yahei'; font-size: 15px; line-height: 35px;" /><br style="color: rgb(85, 85, 85); font-family: 'microsoft yahei'; font-size: 15px; line-height: 35px;" /><span style="color: rgb(85, 85, 85); font-family: 'microsoft yahei'; font-size: 15px; line-height: 35px;">@GenericGenerator的定义: </span><br style="color: rgb(85, 85, 85); font-family: 'microsoft yahei'; font-size: 15px; line-height: 35px;" /><div class="dp-highlighter" id="" style="font-family: Monaco, 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', Consolas, 'Courier New', monospace; width: 659px; overflow: auto; padding: 1px; margin-left: 9px; border-color: rgb(204, 204, 204); color: rgb(85, 85, 85); line-height: 35px; word-break: break-all; word-wrap: break-word; margin-top: 18px !important; margin-right: 0px !important; margin-bottom: 18px !important; background-color: transparent;"><div class="bar" style="padding-left: 45px;"><div class="tools" style="padding: 3px; font-weight: bold; font-stretch: normal; font-size: 9px; line-height: normal; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; color: black; border-left-width: 3px; border-left-style: solid; border-left-color: rgb(108, 226, 108); margin: 0px; background-color: rgb(248, 248, 248);">Java代码  <a target=_blank href="http://xiaogui9317170.iteye.com/blog/283526" title="收藏这段代码" style="text-decoration: none; border: none; padding: 1px; margin: 0px 10px 0px 0px; font-size: 9px; color: rgb(0, 102, 153); display: inline-block; width: 16px; height: 16px; text-indent: -2000px; background-image: none; background-attachment: initial; background-color: inherit; background-size: initial; background-origin: initial; background-clip: initial; background-position: 0% 0%; background-repeat: no-repeat;"><img class="star" src="http://xiaogui9317170.iteye.com/images/icon_star.png" alt="收藏代码" style="border: 0px;" /></a></div></div><ol start="1" class="dp-j" style="margin: 0px 0px 1px; padding: 2px 0px; border: 1px solid rgb(209, 215, 220); list-style-position: initial; list-style-image: initial; color: rgb(43, 145, 175); font-size: 1em; line-height: 1.4em;"><li style="margin: 0px 0px 0px 38px; padding: 0px 0px 0px 10px; border-style: none none none solid; border-left-width: 1px; border-left-color: rgb(209, 215, 220); list-style: decimal-leading-zero outside; color: rgb(92, 92, 92); line-height: 18px; font-size: 1em; background-color: rgb(250, 250, 250);"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;"><span class="annotation" style="margin: 0px; padding: 0px; border: none; color: rgb(100, 100, 100); background-color: inherit;">@Target</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">({PACKAGE, TYPE, METHOD, FIELD})  </span></span></li><li style="margin: 0px 0px 0px 38px; padding: 0px 0px 0px 10px; border-style: none none none solid; border-left-width: 1px; border-left-color: rgb(209, 215, 220); list-style: decimal-leading-zero outside; color: rgb(92, 92, 92); line-height: 18px; font-size: 1em; background-color: rgb(250, 250, 250);"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;"><span class="annotation" style="margin: 0px; padding: 0px; border: none; color: rgb(100, 100, 100); background-color: inherit;">@Retention</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">(RUNTIME)  </span></span></li><li style="margin: 0px 0px 0px 38px; padding: 0px 0px 0px 10px; border-style: none none none solid; border-left-width: 1px; border-left-color: rgb(209, 215, 220); list-style: decimal-leading-zero outside; color: rgb(92, 92, 92); line-height: 18px; font-size: 1em; background-color: rgb(250, 250, 250);"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;"><span class="keyword" style="margin: 0px; padding: 0px; border: none; color: rgb(127, 0, 85); font-weight: bold; background-color: inherit;">public</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;"> </span><span class="keyword" style="margin: 0px; padding: 0px; border: none; color: rgb(127, 0, 85); font-weight: bold; background-color: inherit;">@interface</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;"> GenericGenerator {  </span></span></li><li style="margin: 0px 0px 0px 38px; padding: 0px 0px 0px 10px; border-style: none none none solid; border-left-width: 1px; border-left-color: rgb(209, 215, 220); list-style: decimal-leading-zero outside; color: rgb(92, 92, 92); line-height: 18px; font-size: 1em; background-color: rgb(250, 250, 250);"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;"> <span class="comment" style="margin: 0px; padding: 0px; border: none; color: rgb(0, 130, 0); background-color: inherit;">/**</span> </span></li><li style="margin: 0px 0px 0px 38px; padding: 0px 0px 0px 10px; border-style: none none none solid; border-left-width: 1px; border-left-color: rgb(209, 215, 220); list-style: decimal-leading-zero outside; color: rgb(92, 92, 92); line-height: 18px; font-size: 1em; background-color: rgb(250, 250, 250);"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;"><span class="comment" style="margin: 0px; padding: 0px; border: none; color: rgb(0, 130, 0); background-color: inherit;">  * unique generator name</span> </span></li><li style="margin: 0px 0px 0px 38px; padding: 0px 0px 0px 10px; border-style: none none none solid; border-left-width: 1px; border-left-color: rgb(209, 215, 220); list-style: decimal-leading-zero outside; color: rgb(92, 92, 92); line-height: 18px; font-size: 1em; background-color: rgb(250, 250, 250);"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;"><span class="comment" style="margin: 0px; padding: 0px; border: none; color: rgb(0, 130, 0); background-color: inherit;">  */</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">  </span></span></li><li style="margin: 0px 0px 0px 38px; padding: 0px 0px 0px 10px; border-style: none none none solid; border-left-width: 1px; border-left-color: rgb(209, 215, 220); list-style: decimal-leading-zero outside; color: rgb(92, 92, 92); line-height: 18px; font-size: 1em; background-color: rgb(250, 250, 250);"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;"> String name();  </span></li><li style="margin: 0px 0px 0px 38px; padding: 0px 0px 0px 10px; border-style: none none none solid; border-left-width: 1px; border-left-color: rgb(209, 215, 220); list-style: decimal-leading-zero outside; color: rgb(92, 92, 92); line-height: 18px; font-size: 1em; background-color: rgb(250, 250, 250);"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;"> <span class="comment" style="margin: 0px; padding: 0px; border: none; color: rgb(0, 130, 0); background-color: inherit;">/**</span> </span></li><li style="margin: 0px 0px 0px 38px; padding: 0px 0px 0px 10px; border-style: none none none solid; border-left-width: 1px; border-left-color: rgb(209, 215, 220); list-style: decimal-leading-zero outside; color: rgb(92, 92, 92); line-height: 18px; font-size: 1em; background-color: rgb(250, 250, 250);"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;"><span class="comment" style="margin: 0px; padding: 0px; border: none; color: rgb(0, 130, 0); background-color: inherit;">  * Generator strategy either a predefined Hibernate</span> </span></li><li style="margin: 0px 0px 0px 38px; padding: 0px 0px 0px 10px; border-style: none none none solid; border-left-width: 1px; border-left-color: rgb(209, 215, 220); list-style: decimal-leading-zero outside; color: rgb(92, 92, 92); line-height: 18px; font-size: 1em; background-color: rgb(250, 250, 250);"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;"><span class="comment" style="margin: 0px; padding: 0px; border: none; color: rgb(0, 130, 0); background-color: inherit;">  * strategy or a fully qualified class name.</span> </span></li><li style="margin: 0px 0px 0px 38px; padding: 0px 0px 0px 10px; border-style: none none none solid; border-left-width: 1px; border-left-color: rgb(209, 215, 220); list-style: decimal-leading-zero outside; color: rgb(92, 92, 92); line-height: 18px; font-size: 1em; background-color: rgb(250, 250, 250);"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;"><span class="comment" style="margin: 0px; padding: 0px; border: none; color: rgb(0, 130, 0); background-color: inherit;">  */</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">  </span></span></li><li style="margin: 0px 0px 0px 38px; padding: 0px 0px 0px 10px; border-style: none none none solid; border-left-width: 1px; border-left-color: rgb(209, 215, 220); list-style: decimal-leading-zero outside; color: rgb(92, 92, 92); line-height: 18px; font-size: 1em; background-color: rgb(250, 250, 250);"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;"> String strategy();  </span></li><li style="margin: 0px 0px 0px 38px; padding: 0px 0px 0px 10px; border-style: none none none solid; border-left-width: 1px; border-left-color: rgb(209, 215, 220); list-style: decimal-leading-zero outside; color: rgb(92, 92, 92); line-height: 18px; font-size: 1em; background-color: rgb(250, 250, 250);"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;"> <span class="comment" style="margin: 0px; padding: 0px; border: none; color: rgb(0, 130, 0); background-color: inherit;">/**</span> </span></li><li style="margin: 0px 0px 0px 38px; padding: 0px 0px 0px 10px; border-style: none none none solid; border-left-width: 1px; border-left-color: rgb(209, 215, 220); list-style: decimal-leading-zero outside; color: rgb(92, 92, 92); line-height: 18px; font-size: 1em; background-color: rgb(250, 250, 250);"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;"><span class="comment" style="margin: 0px; padding: 0px; border: none; color: rgb(0, 130, 0); background-color: inherit;">  * Optional generator parameters</span> </span></li><li style="margin: 0px 0px 0px 38px; padding: 0px 0px 0px 10px; border-style: none none none solid; border-left-width: 1px; border-left-color: rgb(209, 215, 220); list-style: decimal-leading-zero outside; color: rgb(92, 92, 92); line-height: 18px; font-size: 1em; background-color: rgb(250, 250, 250);"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;"><span class="comment" style="margin: 0px; padding: 0px; border: none; color: rgb(0, 130, 0); background-color: inherit;">  */</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">  </span></span></li><li style="margin: 0px 0px 0px 38px; padding: 0px 0px 0px 10px; border-style: none none none solid; border-left-width: 1px; border-left-color: rgb(209, 215, 220); list-style: decimal-leading-zero outside; color: rgb(92, 92, 92); line-height: 18px; font-size: 1em; background-color: rgb(250, 250, 250);"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;"> Parameter[] parameters() <span class="keyword" style="margin: 0px; padding: 0px; border: none; color: rgb(127, 0, 85); font-weight: bold; background-color: inherit;">default</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;"> {};  </span></span></li><li style="margin: 0px 0px 0px 38px; padding: 0px 0px 0px 10px; border-style: none none none solid; border-left-width: 1px; border-left-color: rgb(209, 215, 220); list-style: decimal-leading-zero outside; color: rgb(92, 92, 92); line-height: 18px; font-size: 1em; background-color: rgb(250, 250, 250);"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;">}  </span></li></ol></div><br style="color: rgb(85, 85, 85); font-family: 'microsoft yahei'; font-size: 15px; line-height: 35px;" /><br style="color: rgb(85, 85, 85); font-family: 'microsoft yahei'; font-size: 15px; line-height: 35px;" /><span style="color: rgb(85, 85, 85); font-family: 'microsoft yahei'; font-size: 15px; line-height: 35px;">name属性指定生成器名称。 </span><br style="color: rgb(85, 85, 85); font-family: 'microsoft yahei'; font-size: 15px; line-height: 35px;" /><span style="color: rgb(85, 85, 85); font-family: 'microsoft yahei'; font-size: 15px; line-height: 35px;">strategy属性指定具体生成器的类名。 </span><br style="color: rgb(85, 85, 85); font-family: 'microsoft yahei'; font-size: 15px; line-height: 35px;" /><span style="color: rgb(85, 85, 85); font-family: 'microsoft yahei'; font-size: 15px; line-height: 35px;">parameters得到strategy指定的具体生成器所用到的参数。 </span><br style="color: rgb(85, 85, 85); font-family: 'microsoft yahei'; font-size: 15px; line-height: 35px;" /><br style="color: rgb(85, 85, 85); font-family: 'microsoft yahei'; font-size: 15px; line-height: 35px;" /><span style="color: rgb(85, 85, 85); font-family: 'microsoft yahei'; font-size: 15px; line-height: 35px;">对于这些hibernate主键生成策略和各自的具体生成器之间的关系,在org.hibernate.id.IdentifierGeneratorFactory中指定了, </span><br style="color: rgb(85, 85, 85); font-family: 'microsoft yahei'; font-size: 15px; line-height: 35px;" /><div class="dp-highlighter" id="" style="font-family: Monaco, 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', Consolas, 'Courier New', monospace; width: 659px; overflow: auto; padding: 1px; margin-left: 9px; border-color: rgb(204, 204, 204); color: rgb(85, 85, 85); line-height: 35px; word-break: break-all; word-wrap: break-word; margin-top: 18px !important; margin-right: 0px !important; margin-bottom: 18px !important; background-color: transparent;"><div class="bar" style="padding-left: 45px;"><div class="tools" style="padding: 3px; font-weight: bold; font-stretch: normal; font-size: 9px; line-height: normal; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; color: black; border-left-width: 3px; border-left-style: solid; border-left-color: rgb(108, 226, 108); margin: 0px; background-color: rgb(248, 248, 248);">Java代码  <a target=_blank href="http://xiaogui9317170.iteye.com/blog/283526" title="收藏这段代码" style="text-decoration: none; border: none; padding: 1px; margin: 0px 10px 0px 0px; font-size: 9px; color: rgb(0, 102, 153); display: inline-block; width: 16px; height: 16px; text-indent: -2000px; background-image: none; background-attachment: initial; background-color: inherit; background-size: initial; background-origin: initial; background-clip: initial; background-position: 0% 0%; background-repeat: no-repeat;"><img class="star" src="http://xiaogui9317170.iteye.com/images/icon_star.png" alt="收藏代码" style="border: 0px;" /></a></div></div><ol start="1" class="dp-j" style="margin: 0px 0px 1px; padding: 2px 0px; border: 1px solid rgb(209, 215, 220); list-style-position: initial; list-style-image: initial; color: rgb(43, 145, 175); font-size: 1em; line-height: 1.4em;"><li style="margin: 0px 0px 0px 38px; padding: 0px 0px 0px 10px; border-style: none none none solid; border-left-width: 1px; border-left-color: rgb(209, 215, 220); list-style: decimal-leading-zero outside; color: rgb(92, 92, 92); line-height: 18px; font-size: 1em; background-color: rgb(250, 250, 250);"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;"><span class="keyword" style="margin: 0px; padding: 0px; border: none; color: rgb(127, 0, 85); font-weight: bold; background-color: inherit;">static</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;"> {  </span></span></li><li style="margin: 0px 0px 0px 38px; padding: 0px 0px 0px 10px; border-style: none none none solid; border-left-width: 1px; border-left-color: rgb(209, 215, 220); list-style: decimal-leading-zero outside; color: rgb(92, 92, 92); line-height: 18px; font-size: 1em; background-color: rgb(250, 250, 250);"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;">  GENERATORS.put(<span class="string" style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit;">"uuid"</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">, UUIDHexGenerator.</span><span class="keyword" style="margin: 0px; padding: 0px; border: none; color: rgb(127, 0, 85); font-weight: bold; background-color: inherit;">class</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">);  </span></span></li><li style="margin: 0px 0px 0px 38px; padding: 0px 0px 0px 10px; border-style: none none none solid; border-left-width: 1px; border-left-color: rgb(209, 215, 220); list-style: decimal-leading-zero outside; color: rgb(92, 92, 92); line-height: 18px; font-size: 1em; background-color: rgb(250, 250, 250);"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;">  GENERATORS.put(<span class="string" style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit;">"hilo"</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">, TableHiLoGenerator.</span><span class="keyword" style="margin: 0px; padding: 0px; border: none; color: rgb(127, 0, 85); font-weight: bold; background-color: inherit;">class</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">);  </span></span></li><li style="margin: 0px 0px 0px 38px; padding: 0px 0px 0px 10px; border-style: none none none solid; border-left-width: 1px; border-left-color: rgb(209, 215, 220); list-style: decimal-leading-zero outside; color: rgb(92, 92, 92); line-height: 18px; font-size: 1em; background-color: rgb(250, 250, 250);"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;">  GENERATORS.put(<span class="string" style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit;">"assigned"</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">, Assigned.</span><span class="keyword" style="margin: 0px; padding: 0px; border: none; color: rgb(127, 0, 85); font-weight: bold; background-color: inherit;">class</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">);  </span></span></li><li style="margin: 0px 0px 0px 38px; padding: 0px 0px 0px 10px; border-style: none none none solid; border-left-width: 1px; border-left-color: rgb(209, 215, 220); list-style: decimal-leading-zero outside; color: rgb(92, 92, 92); line-height: 18px; font-size: 1em; background-color: rgb(250, 250, 250);"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;">  GENERATORS.put(<span class="string" style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit;">"identity"</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">, IdentityGenerator.</span><span class="keyword" style="margin: 0px; padding: 0px; border: none; color: rgb(127, 0, 85); font-weight: bold; background-color: inherit;">class</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">);  </span></span></li><li style="margin: 0px 0px 0px 38px; padding: 0px 0px 0px 10px; border-style: none none none solid; border-left-width: 1px; border-left-color: rgb(209, 215, 220); list-style: decimal-leading-zero outside; color: rgb(92, 92, 92); line-height: 18px; font-size: 1em; background-color: rgb(250, 250, 250);"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;">  GENERATORS.put(<span class="string" style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit;">"select"</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">, SelectGenerator.</span><span class="keyword" style="margin: 0px; padding: 0px; border: none; color: rgb(127, 0, 85); font-weight: bold; background-color: inherit;">class</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">);  </span></span></li><li style="margin: 0px 0px 0px 38px; padding: 0px 0px 0px 10px; border-style: none none none solid; border-left-width: 1px; border-left-color: rgb(209, 215, 220); list-style: decimal-leading-zero outside; color: rgb(92, 92, 92); line-height: 18px; font-size: 1em; background-color: rgb(250, 250, 250);"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;">  GENERATORS.put(<span class="string" style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit;">"sequence"</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">, SequenceGenerator.</span><span class="keyword" style="margin: 0px; padding: 0px; border: none; color: rgb(127, 0, 85); font-weight: bold; background-color: inherit;">class</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">);  </span></span></li><li style="margin: 0px 0px 0px 38px; padding: 0px 0px 0px 10px; border-style: none none none solid; border-left-width: 1px; border-left-color: rgb(209, 215, 220); list-style: decimal-leading-zero outside; color: rgb(92, 92, 92); line-height: 18px; font-size: 1em; background-color: rgb(250, 250, 250);"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;">  GENERATORS.put(<span class="string" style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit;">"seqhilo"</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">, SequenceHiLoGenerator.</span><span class="keyword" style="margin: 0px; padding: 0px; border: none; color: rgb(127, 0, 85); font-weight: bold; background-color: inherit;">class</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">);  </span></span></li><li style="margin: 0px 0px 0px 38px; padding: 0px 0px 0px 10px; border-style: none none none solid; border-left-width: 1px; border-left-color: rgb(209, 215, 220); list-style: decimal-leading-zero outside; color: rgb(92, 92, 92); line-height: 18px; font-size: 1em; background-color: rgb(250, 250, 250);"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;">  GENERATORS.put(<span class="string" style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit;">"increment"</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">, IncrementGenerator.</span><span class="keyword" style="margin: 0px; padding: 0px; border: none; color: rgb(127, 0, 85); font-weight: bold; background-color: inherit;">class</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">);  </span></span></li><li style="margin: 0px 0px 0px 38px; padding: 0px 0px 0px 10px; border-style: none none none solid; border-left-width: 1px; border-left-color: rgb(209, 215, 220); list-style: decimal-leading-zero outside; color: rgb(92, 92, 92); line-height: 18px; font-size: 1em; background-color: rgb(250, 250, 250);"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;">  GENERATORS.put(<span class="string" style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit;">"foreign"</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">, ForeignGenerator.</span><span class="keyword" style="margin: 0px; padding: 0px; border: none; color: rgb(127, 0, 85); font-weight: bold; background-color: inherit;">class</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">);  </span></span></li><li style="margin: 0px 0px 0px 38px; padding: 0px 0px 0px 10px; border-style: none none none solid; border-left-width: 1px; border-left-color: rgb(209, 215, 220); list-style: decimal-leading-zero outside; color: rgb(92, 92, 92); line-height: 18px; font-size: 1em; background-color: rgb(250, 250, 250);"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;">  GENERATORS.put(<span class="string" style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit;">"guid"</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">, GUIDGenerator.</span><span class="keyword" style="margin: 0px; padding: 0px; border: none; color: rgb(127, 0, 85); font-weight: bold; background-color: inherit;">class</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">);  </span></span></li><li style="margin: 0px 0px 0px 38px; padding: 0px 0px 0px 10px; border-style: none none none solid; border-left-width: 1px; border-left-color: rgb(209, 215, 220); list-style: decimal-leading-zero outside; color: rgb(92, 92, 92); line-height: 18px; font-size: 1em; background-color: rgb(250, 250, 250);"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;">  GENERATORS.put(<span class="string" style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit;">"uuid.hex"</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">, UUIDHexGenerator.</span><span class="keyword" style="margin: 0px; padding: 0px; border: none; color: rgb(127, 0, 85); font-weight: bold; background-color: inherit;">class</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">); </span><span class="comment" style="margin: 0px; padding: 0px; border: none; color: rgb(0, 130, 0); background-color: inherit;">//uuid.hex is deprecated</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">  </span></span></li><li style="margin: 0px 0px 0px 38px; padding: 0px 0px 0px 10px; border-style: none none none solid; border-left-width: 1px; border-left-color: rgb(209, 215, 220); list-style: decimal-leading-zero outside; color: rgb(92, 92, 92); line-height: 18px; font-size: 1em; background-color: rgb(250, 250, 250);"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;">  GENERATORS.put(<span class="string" style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit;">"sequence-identity"</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">, SequenceIdentityGenerator.</span><span class="keyword" style="margin: 0px; padding: 0px; border: none; color: rgb(127, 0, 85); font-weight: bold; background-color: inherit;">class</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">);  </span></span></li><li style="margin: 0px 0px 0px 38px; padding: 0px 0px 0px 10px; border-style: none none none solid; border-left-width: 1px; border-left-color: rgb(209, 215, 220); list-style: decimal-leading-zero outside; color: rgb(92, 92, 92); line-height: 18px; font-size: 1em; background-color: rgb(250, 250, 250);"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;">}  </span></li></ol></div><br style="color: rgb(85, 85, 85); font-family: 'microsoft yahei'; font-size: 15px; line-height: 35px;" /><span style="color: rgb(85, 85, 85); font-family: 'microsoft yahei'; font-size: 15px; line-height: 35px;">上面十二种策略,加上native,hibernate一共默认支持十三种生成策略。 </span><br style="color: rgb(85, 85, 85); font-family: 'microsoft yahei'; font-size: 15px; line-height: 35px;" /><br style="color: rgb(85, 85, 85); font-family: 'microsoft yahei'; font-size: 15px; line-height: 35px;" /><span style="color: rgb(85, 85, 85); font-family: 'microsoft yahei'; font-size: 15px; line-height: 35px;">1、native </span><br style="color: rgb(85, 85, 85); font-family: 'microsoft yahei'; font-size: 15px; line-height: 35px;" /><div class="dp-highlighter" id="" style="font-family: Monaco, 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', Consolas, 'Courier New', monospace; width: 659px; overflow: auto; padding: 1px; margin-left: 9px; border-color: rgb(204, 204, 204); color: rgb(85, 85, 85); line-height: 35px; word-break: break-all; word-wrap: break-word; margin-top: 18px !important; margin-right: 0px !important; margin-bottom: 18px !important; background-color: transparent;"><div class="bar" style="padding-left: 45px;"><div class="tools" style="padding: 3px; font-weight: bold; font-stretch: normal; font-size: 9px; line-height: normal; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; color: black; border-left-width: 3px; border-left-style: solid; border-left-color: rgb(108, 226, 108); margin: 0px; background-color: rgb(248, 248, 248);">Java代码  <a target=_blank href="http://xiaogui9317170.iteye.com/blog/283526" title="收藏这段代码" style="text-decoration: none; border: none; padding: 1px; margin: 0px 10px 0px 0px; font-size: 9px; color: rgb(0, 102, 153); display: inline-block; width: 16px; height: 16px; text-indent: -2000px; background-image: none; background-attachment: initial; background-color: inherit; background-size: initial; background-origin: initial; background-clip: initial; background-position: 0% 0%; background-repeat: no-repeat;"><img class="star" src="http://xiaogui9317170.iteye.com/images/icon_star.png" alt="收藏代码" style="border: 0px;" /></a></div></div><ol start="1" class="dp-j" style="margin: 0px 0px 1px; padding: 2px 0px; border: 1px solid rgb(209, 215, 220); list-style-position: initial; list-style-image: initial; color: rgb(43, 145, 175); font-size: 1em; line-height: 1.4em;"><li style="margin: 0px 0px 0px 38px; padding: 0px 0px 0px 10px; border-style: none none none solid; border-left-width: 1px; border-left-color: rgb(209, 215, 220); list-style: decimal-leading-zero outside; color: rgb(92, 92, 92); line-height: 18px; font-size: 1em; background-color: rgb(250, 250, 250);"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;"><span class="annotation" style="margin: 0px; padding: 0px; border: none; color: rgb(100, 100, 100); background-color: inherit;">@GeneratedValue</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">(generator = </span><span class="string" style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit;">"paymentableGenerator"</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">)    </span></span></li><li style="margin: 0px 0px 0px 38px; padding: 0px 0px 0px 10px; border-style: none none none solid; border-left-width: 1px; border-left-color: rgb(209, 215, 220); list-style: decimal-leading-zero outside; color: rgb(92, 92, 92); line-height: 18px; font-size: 1em; background-color: rgb(250, 250, 250);"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;"><span class="annotation" style="margin: 0px; padding: 0px; border: none; color: rgb(100, 100, 100); background-color: inherit;">@GenericGenerator</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">(name = </span><span class="string" style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit;">"paymentableGenerator"</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">, strategy = </span><span class="string" style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit;">"native"</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">)   </span></span></li></ol></div><br style="color: rgb(85, 85, 85); font-family: 'microsoft yahei'; font-size: 15px; line-height: 35px;" /><span style="color: rgb(85, 85, 85); font-family: 'microsoft yahei'; font-size: 15px; line-height: 35px;">2、uuid </span><br style="color: rgb(85, 85, 85); font-family: 'microsoft yahei'; font-size: 15px; line-height: 35px;" /><div class="dp-highlighter" id="" style="font-family: Monaco, 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', Consolas, 'Courier New', monospace; width: 659px; overflow: auto; padding: 1px; margin-left: 9px; border-color: rgb(204, 204, 204); color: rgb(85, 85, 85); line-height: 35px; word-break: break-all; word-wrap: break-word; margin-top: 18px !important; margin-right: 0px !important; margin-bottom: 18px !important; background-color: transparent;"><div class="bar" style="padding-left: 45px;"><div class="tools" style="padding: 3px; font-weight: bold; font-stretch: normal; font-size: 9px; line-height: normal; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; color: black; border-left-width: 3px; border-left-style: solid; border-left-color: rgb(108, 226, 108); margin: 0px; background-color: rgb(248, 248, 248);">Java代码  <a target=_blank href="http://xiaogui9317170.iteye.com/blog/283526" title="收藏这段代码" style="text-decoration: none; border: none; padding: 1px; margin: 0px 10px 0px 0px; font-size: 9px; color: rgb(0, 102, 153); display: inline-block; width: 16px; height: 16px; text-indent: -2000px; background-image: none; background-attachment: initial; background-color: inherit; background-size: initial; background-origin: initial; background-clip: initial; background-position: 0% 0%; background-repeat: no-repeat;"><img class="star" src="http://xiaogui9317170.iteye.com/images/icon_star.png" alt="收藏代码" style="border: 0px;" /></a></div></div><ol start="1" class="dp-j" style="margin: 0px 0px 1px; padding: 2px 0px; border: 1px solid rgb(209, 215, 220); list-style-position: initial; list-style-image: initial; color: rgb(43, 145, 175); font-size: 1em; line-height: 1.4em;"><li style="margin: 0px 0px 0px 38px; padding: 0px 0px 0px 10px; border-style: none none none solid; border-left-width: 1px; border-left-color: rgb(209, 215, 220); list-style: decimal-leading-zero outside; color: rgb(92, 92, 92); line-height: 18px; font-size: 1em; background-color: rgb(250, 250, 250);"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;"><span class="annotation" style="margin: 0px; padding: 0px; border: none; color: rgb(100, 100, 100); background-color: inherit;">@GeneratedValue</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">(generator = </span><span class="string" style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit;">"paymentableGenerator"</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">)    </span></span></li><li style="margin: 0px 0px 0px 38px; padding: 0px 0px 0px 10px; border-style: none none none solid; border-left-width: 1px; border-left-color: rgb(209, 215, 220); list-style: decimal-leading-zero outside; color: rgb(92, 92, 92); line-height: 18px; font-size: 1em; background-color: rgb(250, 250, 250);"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;"><span class="annotation" style="margin: 0px; padding: 0px; border: none; color: rgb(100, 100, 100); background-color: inherit;">@GenericGenerator</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">(name = </span><span class="string" style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit;">"paymentableGenerator"</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">, strategy = </span><span class="string" style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit;">"uuid"</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">)   </span></span></li></ol></div><br style="color: rgb(85, 85, 85); font-family: 'microsoft yahei'; font-size: 15px; line-height: 35px;" /><span style="color: rgb(85, 85, 85); font-family: 'microsoft yahei'; font-size: 15px; line-height: 35px;">3、hilo </span><br style="color: rgb(85, 85, 85); font-family: 'microsoft yahei'; font-size: 15px; line-height: 35px;" /><div class="dp-highlighter" id="" style="font-family: Monaco, 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', Consolas, 'Courier New', monospace; width: 659px; overflow: auto; padding: 1px; margin-left: 9px; border-color: rgb(204, 204, 204); color: rgb(85, 85, 85); line-height: 35px; word-break: break-all; word-wrap: break-word; margin-top: 18px !important; margin-right: 0px !important; margin-bottom: 18px !important; background-color: transparent;"><div class="bar" style="padding-left: 45px;"><div class="tools" style="padding: 3px; font-weight: bold; font-stretch: normal; font-size: 9px; line-height: normal; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; color: black; border-left-width: 3px; border-left-style: solid; border-left-color: rgb(108, 226, 108); margin: 0px; background-color: rgb(248, 248, 248);">Java代码  <a target=_blank href="http://xiaogui9317170.iteye.com/blog/283526" title="收藏这段代码" style="text-decoration: none; border: none; padding: 1px; margin: 0px 10px 0px 0px; font-size: 9px; color: rgb(0, 102, 153); display: inline-block; width: 16px; height: 16px; text-indent: -2000px; background-image: none; background-attachment: initial; background-color: inherit; background-size: initial; background-origin: initial; background-clip: initial; background-position: 0% 0%; background-repeat: no-repeat;"><img class="star" src="http://xiaogui9317170.iteye.com/images/icon_star.png" alt="收藏代码" style="border: 0px;" /></a></div></div><ol start="1" class="dp-j" style="margin: 0px 0px 1px; padding: 2px 0px; border: 1px solid rgb(209, 215, 220); list-style-position: initial; list-style-image: initial; color: rgb(43, 145, 175); font-size: 1em; line-height: 1.4em;"><li style="margin: 0px 0px 0px 38px; padding: 0px 0px 0px 10px; border-style: none none none solid; border-left-width: 1px; border-left-color: rgb(209, 215, 220); list-style: decimal-leading-zero outside; color: rgb(92, 92, 92); line-height: 18px; font-size: 1em; background-color: rgb(250, 250, 250);"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;"><span class="annotation" style="margin: 0px; padding: 0px; border: none; color: rgb(100, 100, 100); background-color: inherit;">@GeneratedValue</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">(generator = </span><span class="string" style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit;">"paymentableGenerator"</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">)    </span></span></li><li style="margin: 0px 0px 0px 38px; padding: 0px 0px 0px 10px; border-style: none none none solid; border-left-width: 1px; border-left-color: rgb(209, 215, 220); list-style: decimal-leading-zero outside; color: rgb(92, 92, 92); line-height: 18px; font-size: 1em; background-color: rgb(250, 250, 250);"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;"><span class="annotation" style="margin: 0px; padding: 0px; border: none; color: rgb(100, 100, 100); background-color: inherit;">@GenericGenerator</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">(name = </span><span class="string" style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit;">"paymentableGenerator"</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">, strategy = </span><span class="string" style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit;">"hilo"</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">)   </span></span></li></ol></div><br style="color: rgb(85, 85, 85); font-family: 'microsoft yahei'; font-size: 15px; line-height: 35px;" /><span style="color: rgb(85, 85, 85); font-family: 'microsoft yahei'; font-size: 15px; line-height: 35px;">4、assigned </span><br style="color: rgb(85, 85, 85); font-family: 'microsoft yahei'; font-size: 15px; line-height: 35px;" /><div class="dp-highlighter" id="" style="font-family: Monaco, 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', Consolas, 'Courier New', monospace; width: 659px; overflow: auto; padding: 1px; margin-left: 9px; border-color: rgb(204, 204, 204); color: rgb(85, 85, 85); line-height: 35px; word-break: break-all; word-wrap: break-word; margin-top: 18px !important; margin-right: 0px !important; margin-bottom: 18px !important; background-color: transparent;"><div class="bar" style="padding-left: 45px;"><div class="tools" style="padding: 3px; font-weight: bold; font-stretch: normal; font-size: 9px; line-height: normal; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; color: black; border-left-width: 3px; border-left-style: solid; border-left-color: rgb(108, 226, 108); margin: 0px; background-color: rgb(248, 248, 248);">Java代码  <a target=_blank href="http://xiaogui9317170.iteye.com/blog/283526" title="收藏这段代码" style="text-decoration: none; border: none; padding: 1px; margin: 0px 10px 0px 0px; font-size: 9px; color: rgb(0, 102, 153); display: inline-block; width: 16px; height: 16px; text-indent: -2000px; background-image: none; background-attachment: initial; background-color: inherit; background-size: initial; background-origin: initial; background-clip: initial; background-position: 0% 0%; background-repeat: no-repeat;"><img class="star" src="http://xiaogui9317170.iteye.com/images/icon_star.png" alt="收藏代码" style="border: 0px;" /></a></div></div><ol start="1" class="dp-j" style="margin: 0px 0px 1px; padding: 2px 0px; border: 1px solid rgb(209, 215, 220); list-style-position: initial; list-style-image: initial; color: rgb(43, 145, 175); font-size: 1em; line-height: 1.4em;"><li style="margin: 0px 0px 0px 38px; padding: 0px 0px 0px 10px; border-style: none none none solid; border-left-width: 1px; border-left-color: rgb(209, 215, 220); list-style: decimal-leading-zero outside; color: rgb(92, 92, 92); line-height: 18px; font-size: 1em; background-color: rgb(250, 250, 250);"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;"><span class="annotation" style="margin: 0px; padding: 0px; border: none; color: rgb(100, 100, 100); background-color: inherit;">@GeneratedValue</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">(generator = </span><span class="string" style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit;">"paymentableGenerator"</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">)    </span></span></li><li style="margin: 0px 0px 0px 38px; padding: 0px 0px 0px 10px; border-style: none none none solid; border-left-width: 1px; border-left-color: rgb(209, 215, 220); list-style: decimal-leading-zero outside; color: rgb(92, 92, 92); line-height: 18px; font-size: 1em; background-color: rgb(250, 250, 250);"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;"><span class="annotation" style="margin: 0px; padding: 0px; border: none; color: rgb(100, 100, 100); background-color: inherit;">@GenericGenerator</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">(name = </span><span class="string" style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit;">"paymentableGenerator"</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">, strategy = </span><span class="string" style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit;">"assigned"</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">)   </span></span></li></ol></div><br style="color: rgb(85, 85, 85); font-family: 'microsoft yahei'; font-size: 15px; line-height: 35px;" /><span style="color: rgb(85, 85, 85); font-family: 'microsoft yahei'; font-size: 15px; line-height: 35px;">5、identity </span><br style="color: rgb(85, 85, 85); font-family: 'microsoft yahei'; font-size: 15px; line-height: 35px;" /><div class="dp-highlighter" id="" style="font-family: Monaco, 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', Consolas, 'Courier New', monospace; width: 659px; overflow: auto; padding: 1px; margin-left: 9px; border-color: rgb(204, 204, 204); color: rgb(85, 85, 85); line-height: 35px; word-break: break-all; word-wrap: break-word; margin-top: 18px !important; margin-right: 0px !important; margin-bottom: 18px !important; background-color: transparent;"><div class="bar" style="padding-left: 45px;"><div class="tools" style="padding: 3px; font-weight: bold; font-stretch: normal; font-size: 9px; line-height: normal; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; color: black; border-left-width: 3px; border-left-style: solid; border-left-color: rgb(108, 226, 108); margin: 0px; background-color: rgb(248, 248, 248);">Java代码  <a target=_blank href="http://xiaogui9317170.iteye.com/blog/283526" title="收藏这段代码" style="text-decoration: none; border: none; padding: 1px; margin: 0px 10px 0px 0px; font-size: 9px; color: rgb(0, 102, 153); display: inline-block; width: 16px; height: 16px; text-indent: -2000px; background-image: none; background-attachment: initial; background-color: inherit; background-size: initial; background-origin: initial; background-clip: initial; background-position: 0% 0%; background-repeat: no-repeat;"><img class="star" src="http://xiaogui9317170.iteye.com/images/icon_star.png" alt="收藏代码" style="border: 0px;" /></a></div></div><ol start="1" class="dp-j" style="margin: 0px 0px 1px; padding: 2px 0px; border: 1px solid rgb(209, 215, 220); list-style-position: initial; list-style-image: initial; color: rgb(43, 145, 175); font-size: 1em; line-height: 1.4em;"><li style="margin: 0px 0px 0px 38px; padding: 0px 0px 0px 10px; border-style: none none none solid; border-left-width: 1px; border-left-color: rgb(209, 215, 220); list-style: decimal-leading-zero outside; color: rgb(92, 92, 92); line-height: 18px; font-size: 1em; background-color: rgb(250, 250, 250);"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;"><span class="annotation" style="margin: 0px; padding: 0px; border: none; color: rgb(100, 100, 100); background-color: inherit;">@GeneratedValue</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">(generator = </span><span class="string" style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit;">"paymentableGenerator"</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">)    </span></span></li><li style="margin: 0px 0px 0px 38px; padding: 0px 0px 0px 10px; border-style: none none none solid; border-left-width: 1px; border-left-color: rgb(209, 215, 220); list-style: decimal-leading-zero outside; color: rgb(92, 92, 92); line-height: 18px; font-size: 1em; background-color: rgb(250, 250, 250);"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;"><span class="annotation" style="margin: 0px; padding: 0px; border: none; color: rgb(100, 100, 100); background-color: inherit;">@GenericGenerator</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">(name = </span><span class="string" style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit;">"paymentableGenerator"</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">, strategy = </span><span class="string" style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit;">"identity"</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">)   </span></span></li></ol></div><br style="color: rgb(85, 85, 85); font-family: 'microsoft yahei'; font-size: 15px; line-height: 35px;" /><span style="color: rgb(85, 85, 85); font-family: 'microsoft yahei'; font-size: 15px; line-height: 35px;">6、select </span><br style="color: rgb(85, 85, 85); font-family: 'microsoft yahei'; font-size: 15px; line-height: 35px;" /><div class="dp-highlighter" id="" style="font-family: Monaco, 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', Consolas, 'Courier New', monospace; width: 659px; overflow: auto; padding: 1px; margin-left: 9px; border-color: rgb(204, 204, 204); color: rgb(85, 85, 85); line-height: 35px; word-break: break-all; word-wrap: break-word; margin-top: 18px !important; margin-right: 0px !important; margin-bottom: 18px !important; background-color: transparent;"><div class="bar" style="padding-left: 45px;"><div class="tools" style="padding: 3px; font-weight: bold; font-stretch: normal; font-size: 9px; line-height: normal; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; color: black; border-left-width: 3px; border-left-style: solid; border-left-color: rgb(108, 226, 108); margin: 0px; background-color: rgb(248, 248, 248);">Java代码  <a target=_blank href="http://xiaogui9317170.iteye.com/blog/283526" title="收藏这段代码" style="text-decoration: none; border: none; padding: 1px; margin: 0px 10px 0px 0px; font-size: 9px; color: rgb(0, 102, 153); display: inline-block; width: 16px; height: 16px; text-indent: -2000px; background-image: none; background-attachment: initial; background-color: inherit; background-size: initial; background-origin: initial; background-clip: initial; background-position: 0% 0%; background-repeat: no-repeat;"><img class="star" src="http://xiaogui9317170.iteye.com/images/icon_star.png" alt="收藏代码" style="border: 0px;" /></a></div></div><ol start="1" class="dp-j" style="margin: 0px 0px 1px; padding: 2px 0px; border: 1px solid rgb(209, 215, 220); list-style-position: initial; list-style-image: initial; color: rgb(43, 145, 175); font-size: 1em; line-height: 1.4em;"><li style="margin: 0px 0px 0px 38px; padding: 0px 0px 0px 10px; border-style: none none none solid; border-left-width: 1px; border-left-color: rgb(209, 215, 220); list-style: decimal-leading-zero outside; color: rgb(92, 92, 92); line-height: 18px; font-size: 1em; background-color: rgb(250, 250, 250);"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;"><span class="annotation" style="margin: 0px; padding: 0px; border: none; color: rgb(100, 100, 100); background-color: inherit;">@GeneratedValue</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">(generator = </span><span class="string" style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit;">"paymentableGenerator"</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">)  </span></span></li><li style="margin: 0px 0px 0px 38px; padding: 0px 0px 0px 10px; border-style: none none none solid; border-left-width: 1px; border-left-color: rgb(209, 215, 220); list-style: decimal-leading-zero outside; color: rgb(92, 92, 92); line-height: 18px; font-size: 1em; background-color: rgb(250, 250, 250);"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;"><span class="annotation" style="margin: 0px; padding: 0px; border: none; color: rgb(100, 100, 100); background-color: inherit;">@GenericGenerator</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">(name=</span><span class="string" style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit;">"select"</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">, strategy=</span><span class="string" style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit;">"select"</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">,  </span></span></li><li style="margin: 0px 0px 0px 38px; padding: 0px 0px 0px 10px; border-style: none none none solid; border-left-width: 1px; border-left-color: rgb(209, 215, 220); list-style: decimal-leading-zero outside; color: rgb(92, 92, 92); line-height: 18px; font-size: 1em; background-color: rgb(250, 250, 250);"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;">     parameters = { <span class="annotation" style="margin: 0px; padding: 0px; border: none; color: rgb(100, 100, 100); background-color: inherit;">@Parameter</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">(name = </span><span class="string" style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit;">"key"</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">, value = </span><span class="string" style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit;">"idstoerung"</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">) })  </span></span></li></ol></div><br style="color: rgb(85, 85, 85); font-family: 'microsoft yahei'; font-size: 15px; line-height: 35px;" /><span style="color: rgb(85, 85, 85); font-family: 'microsoft yahei'; font-size: 15px; line-height: 35px;">7、sequence </span><br style="color: rgb(85, 85, 85); font-family: 'microsoft yahei'; font-size: 15px; line-height: 35px;" /><div class="dp-highlighter" id="" style="font-family: Monaco, 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', Consolas, 'Courier New', monospace; width: 659px; overflow: auto; padding: 1px; margin-left: 9px; border-color: rgb(204, 204, 204); color: rgb(85, 85, 85); line-height: 35px; word-break: break-all; word-wrap: break-word; margin-top: 18px !important; margin-right: 0px !important; margin-bottom: 18px !important; background-color: transparent;"><div class="bar" style="padding-left: 45px;"><div class="tools" style="padding: 3px; font-weight: bold; font-stretch: normal; font-size: 9px; line-height: normal; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; color: black; border-left-width: 3px; border-left-style: solid; border-left-color: rgb(108, 226, 108); margin: 0px; background-color: rgb(248, 248, 248);">Java代码  <a target=_blank href="http://xiaogui9317170.iteye.com/blog/283526" title="收藏这段代码" style="text-decoration: none; border: none; padding: 1px; margin: 0px 10px 0px 0px; font-size: 9px; color: rgb(0, 102, 153); display: inline-block; width: 16px; height: 16px; text-indent: -2000px; background-image: none; background-attachment: initial; background-color: inherit; background-size: initial; background-origin: initial; background-clip: initial; background-position: 0% 0%; background-repeat: no-repeat;"><img class="star" src="http://xiaogui9317170.iteye.com/images/icon_star.png" alt="收藏代码" style="border: 0px;" /></a></div></div><ol start="1" class="dp-j" style="margin: 0px 0px 1px; padding: 2px 0px; border: 1px solid rgb(209, 215, 220); list-style-position: initial; list-style-image: initial; color: rgb(43, 145, 175); font-size: 1em; line-height: 1.4em;"><li style="margin: 0px 0px 0px 38px; padding: 0px 0px 0px 10px; border-style: none none none solid; border-left-width: 1px; border-left-color: rgb(209, 215, 220); list-style: decimal-leading-zero outside; color: rgb(92, 92, 92); line-height: 18px; font-size: 1em; background-color: rgb(250, 250, 250);"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;"><span class="annotation" style="margin: 0px; padding: 0px; border: none; color: rgb(100, 100, 100); background-color: inherit;">@GeneratedValue</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">(generator = </span><span class="string" style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit;">"paymentableGenerator"</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">)  </span></span></li><li style="margin: 0px 0px 0px 38px; padding: 0px 0px 0px 10px; border-style: none none none solid; border-left-width: 1px; border-left-color: rgb(209, 215, 220); list-style: decimal-leading-zero outside; color: rgb(92, 92, 92); line-height: 18px; font-size: 1em; background-color: rgb(250, 250, 250);"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;"><span class="annotation" style="margin: 0px; padding: 0px; border: none; color: rgb(100, 100, 100); background-color: inherit;">@GenericGenerator</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">(name = </span><span class="string" style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit;">"paymentableGenerator"</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">, strategy = </span><span class="string" style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit;">"sequence"</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">,   </span></span></li><li style="margin: 0px 0px 0px 38px; padding: 0px 0px 0px 10px; border-style: none none none solid; border-left-width: 1px; border-left-color: rgb(209, 215, 220); list-style: decimal-leading-zero outside; color: rgb(92, 92, 92); line-height: 18px; font-size: 1em; background-color: rgb(250, 250, 250);"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;">         parameters = { <span class="annotation" style="margin: 0px; padding: 0px; border: none; color: rgb(100, 100, 100); background-color: inherit;">@Parameter</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">(name = </span><span class="string" style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit;">"sequence"</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">, value = </span><span class="string" style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit;">"seq_payablemoney"</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">) })  </span></span></li></ol></div><br style="color: rgb(85, 85, 85); font-family: 'microsoft yahei'; font-size: 15px; line-height: 35px;" /><span style="color: rgb(85, 85, 85); font-family: 'microsoft yahei'; font-size: 15px; line-height: 35px;">8、seqhilo </span><br style="color: rgb(85, 85, 85); font-family: 'microsoft yahei'; font-size: 15px; line-height: 35px;" /><div class="dp-highlighter" id="" style="font-family: Monaco, 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', Consolas, 'Courier New', monospace; width: 659px; overflow: auto; padding: 1px; margin-left: 9px; border-color: rgb(204, 204, 204); color: rgb(85, 85, 85); line-height: 35px; word-break: break-all; word-wrap: break-word; margin-top: 18px !important; margin-right: 0px !important; margin-bottom: 18px !important; background-color: transparent;"><div class="bar" style="padding-left: 45px;"><div class="tools" style="padding: 3px; font-weight: bold; font-stretch: normal; font-size: 9px; line-height: normal; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; color: black; border-left-width: 3px; border-left-style: solid; border-left-color: rgb(108, 226, 108); margin: 0px; background-color: rgb(248, 248, 248);">Java代码  <a target=_blank href="http://xiaogui9317170.iteye.com/blog/283526" title="收藏这段代码" style="text-decoration: none; border: none; padding: 1px; margin: 0px 10px 0px 0px; font-size: 9px; color: rgb(0, 102, 153); display: inline-block; width: 16px; height: 16px; text-indent: -2000px; background-image: none; background-attachment: initial; background-color: inherit; background-size: initial; background-origin: initial; background-clip: initial; background-position: 0% 0%; background-repeat: no-repeat;"><img class="star" src="http://xiaogui9317170.iteye.com/images/icon_star.png" alt="收藏代码" style="border: 0px;" /></a></div></div><ol start="1" class="dp-j" style="margin: 0px 0px 1px; padding: 2px 0px; border: 1px solid rgb(209, 215, 220); list-style-position: initial; list-style-image: initial; color: rgb(43, 145, 175); font-size: 1em; line-height: 1.4em;"><li style="margin: 0px 0px 0px 38px; padding: 0px 0px 0px 10px; border-style: none none none solid; border-left-width: 1px; border-left-color: rgb(209, 215, 220); list-style: decimal-leading-zero outside; color: rgb(92, 92, 92); line-height: 18px; font-size: 1em; background-color: rgb(250, 250, 250);"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;"><span class="annotation" style="margin: 0px; padding: 0px; border: none; color: rgb(100, 100, 100); background-color: inherit;">@GeneratedValue</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">(generator = </span><span class="string" style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit;">"paymentableGenerator"</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">)  </span></span></li><li style="margin: 0px 0px 0px 38px; padding: 0px 0px 0px 10px; border-style: none none none solid; border-left-width: 1px; border-left-color: rgb(209, 215, 220); list-style: decimal-leading-zero outside; color: rgb(92, 92, 92); line-height: 18px; font-size: 1em; background-color: rgb(250, 250, 250);"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;"><span class="annotation" style="margin: 0px; padding: 0px; border: none; color: rgb(100, 100, 100); background-color: inherit;">@GenericGenerator</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">(name = </span><span class="string" style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit;">"paymentableGenerator"</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">, strategy = </span><span class="string" style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit;">"seqhilo"</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">,   </span></span></li><li style="margin: 0px 0px 0px 38px; padding: 0px 0px 0px 10px; border-style: none none none solid; border-left-width: 1px; border-left-color: rgb(209, 215, 220); list-style: decimal-leading-zero outside; color: rgb(92, 92, 92); line-height: 18px; font-size: 1em; background-color: rgb(250, 250, 250);"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;">         parameters = { <span class="annotation" style="margin: 0px; padding: 0px; border: none; color: rgb(100, 100, 100); background-color: inherit;">@Parameter</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">(name = </span><span class="string" style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit;">"max_lo"</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">, value = </span><span class="string" style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit;">"5"</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">) })  </span></span></li></ol></div><br style="color: rgb(85, 85, 85); font-family: 'microsoft yahei'; font-size: 15px; line-height: 35px;" /><span style="color: rgb(85, 85, 85); font-family: 'microsoft yahei'; font-size: 15px; line-height: 35px;">9、increment </span><br style="color: rgb(85, 85, 85); font-family: 'microsoft yahei'; font-size: 15px; line-height: 35px;" /><div class="dp-highlighter" id="" style="font-family: Monaco, 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', Consolas, 'Courier New', monospace; width: 659px; overflow: auto; padding: 1px; margin-left: 9px; border-color: rgb(204, 204, 204); color: rgb(85, 85, 85); line-height: 35px; word-break: break-all; word-wrap: break-word; margin-top: 18px !important; margin-right: 0px !important; margin-bottom: 18px !important; background-color: transparent;"><div class="bar" style="padding-left: 45px;"><div class="tools" style="padding: 3px; font-weight: bold; font-stretch: normal; font-size: 9px; line-height: normal; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; color: black; border-left-width: 3px; border-left-style: solid; border-left-color: rgb(108, 226, 108); margin: 0px; background-color: rgb(248, 248, 248);">Java代码  <a target=_blank href="http://xiaogui9317170.iteye.com/blog/283526" title="收藏这段代码" style="text-decoration: none; border: none; padding: 1px; margin: 0px 10px 0px 0px; font-size: 9px; color: rgb(0, 102, 153); display: inline-block; width: 16px; height: 16px; text-indent: -2000px; background-image: none; background-attachment: initial; background-color: inherit; background-size: initial; background-origin: initial; background-clip: initial; background-position: 0% 0%; background-repeat: no-repeat;"><img class="star" src="http://xiaogui9317170.iteye.com/images/icon_star.png" alt="收藏代码" style="border: 0px;" /></a></div></div><ol start="1" class="dp-j" style="margin: 0px 0px 1px; padding: 2px 0px; border: 1px solid rgb(209, 215, 220); list-style-position: initial; list-style-image: initial; color: rgb(43, 145, 175); font-size: 1em; line-height: 1.4em;"><li style="margin: 0px 0px 0px 38px; padding: 0px 0px 0px 10px; border-style: none none none solid; border-left-width: 1px; border-left-color: rgb(209, 215, 220); list-style: decimal-leading-zero outside; color: rgb(92, 92, 92); line-height: 18px; font-size: 1em; background-color: rgb(250, 250, 250);"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;"><span class="annotation" style="margin: 0px; padding: 0px; border: none; color: rgb(100, 100, 100); background-color: inherit;">@GeneratedValue</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">(generator = </span><span class="string" style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit;">"paymentableGenerator"</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">)    </span></span></li><li style="margin: 0px 0px 0px 38px; padding: 0px 0px 0px 10px; border-style: none none none solid; border-left-width: 1px; border-left-color: rgb(209, 215, 220); list-style: decimal-leading-zero outside; color: rgb(92, 92, 92); line-height: 18px; font-size: 1em; background-color: rgb(250, 250, 250);"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;"><span class="annotation" style="margin: 0px; padding: 0px; border: none; color: rgb(100, 100, 100); background-color: inherit;">@GenericGenerator</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">(name = </span><span class="string" style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit;">"paymentableGenerator"</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">, strategy = </span><span class="string" style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit;">"increment"</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">)   </span></span></li></ol></div><br style="color: rgb(85, 85, 85); font-family: 'microsoft yahei'; font-size: 15px; line-height: 35px;" /><span style="color: rgb(85, 85, 85); font-family: 'microsoft yahei'; font-size: 15px; line-height: 35px;">10、foreign </span><br style="color: rgb(85, 85, 85); font-family: 'microsoft yahei'; font-size: 15px; line-height: 35px;" /><div class="dp-highlighter" id="" style="font-family: Monaco, 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', Consolas, 'Courier New', monospace; width: 659px; overflow: auto; padding: 1px; margin-left: 9px; border-color: rgb(204, 204, 204); color: rgb(85, 85, 85); line-height: 35px; word-break: break-all; word-wrap: break-word; margin-top: 18px !important; margin-right: 0px !important; margin-bottom: 18px !important; background-color: transparent;"><div class="bar" style="padding-left: 45px;"><div class="tools" style="padding: 3px; font-weight: bold; font-stretch: normal; font-size: 9px; line-height: normal; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; color: black; border-left-width: 3px; border-left-style: solid; border-left-color: rgb(108, 226, 108); margin: 0px; background-color: rgb(248, 248, 248);">Java代码  <a target=_blank href="http://xiaogui9317170.iteye.com/blog/283526" title="收藏这段代码" style="text-decoration: none; border: none; padding: 1px; margin: 0px 10px 0px 0px; font-size: 9px; color: rgb(0, 102, 153); display: inline-block; width: 16px; height: 16px; text-indent: -2000px; background-image: none; background-attachment: initial; background-color: inherit; background-size: initial; background-origin: initial; background-clip: initial; background-position: 0% 0%; background-repeat: no-repeat;"><img class="star" src="http://xiaogui9317170.iteye.com/images/icon_star.png" alt="收藏代码" style="border: 0px;" /></a></div></div><ol start="1" class="dp-j" style="margin: 0px 0px 1px; padding: 2px 0px; border: 1px solid rgb(209, 215, 220); list-style-position: initial; list-style-image: initial; color: rgb(43, 145, 175); font-size: 1em; line-height: 1.4em;"><li style="margin: 0px 0px 0px 38px; padding: 0px 0px 0px 10px; border-style: none none none solid; border-left-width: 1px; border-left-color: rgb(209, 215, 220); list-style: decimal-leading-zero outside; color: rgb(92, 92, 92); line-height: 18px; font-size: 1em; background-color: rgb(250, 250, 250);"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;"><span class="annotation" style="margin: 0px; padding: 0px; border: none; color: rgb(100, 100, 100); background-color: inherit;">@GeneratedValue</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">(generator = </span><span class="string" style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit;">"idGenerator"</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">)  </span></span></li><li style="margin: 0px 0px 0px 38px; padding: 0px 0px 0px 10px; border-style: none none none solid; border-left-width: 1px; border-left-color: rgb(209, 215, 220); list-style: decimal-leading-zero outside; color: rgb(92, 92, 92); line-height: 18px; font-size: 1em; background-color: rgb(250, 250, 250);"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;"><span class="annotation" style="margin: 0px; padding: 0px; border: none; color: rgb(100, 100, 100); background-color: inherit;">@GenericGenerator</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">(name = </span><span class="string" style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit;">"idGenerator"</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">, strategy = </span><span class="string" style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit;">"foreign"</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">,   </span></span></li><li style="margin: 0px 0px 0px 38px; padding: 0px 0px 0px 10px; border-style: none none none solid; border-left-width: 1px; border-left-color: rgb(209, 215, 220); list-style: decimal-leading-zero outside; color: rgb(92, 92, 92); line-height: 18px; font-size: 1em; background-color: rgb(250, 250, 250);"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;">         parameters = { <span class="annotation" style="margin: 0px; padding: 0px; border: none; color: rgb(100, 100, 100); background-color: inherit;">@Parameter</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">(name = </span><span class="string" style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit;">"property"</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">, value = </span><span class="string" style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit;">"employee"</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">) })  </span></span></li></ol></div><br style="color: rgb(85, 85, 85); font-family: 'microsoft yahei'; font-size: 15px; line-height: 35px;" /><br style="color: rgb(85, 85, 85); font-family: 'microsoft yahei'; font-size: 15px; line-height: 35px;" /><span style="color: rgb(85, 85, 85); font-family: 'microsoft yahei'; font-size: 15px; line-height: 35px;">注意:直接使用@PrimaryKeyJoinColumn 报错(?) </span><br style="color: rgb(85, 85, 85); font-family: 'microsoft yahei'; font-size: 15px; line-height: 35px;" /><div class="dp-highlighter" id="" style="font-family: Monaco, 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', Consolas, 'Courier New', monospace; width: 659px; overflow: auto; padding: 1px; margin-left: 9px; border-color: rgb(204, 204, 204); color: rgb(85, 85, 85); line-height: 35px; word-break: break-all; word-wrap: break-word; margin-top: 18px !important; margin-right: 0px !important; margin-bottom: 18px !important; background-color: transparent;"><div class="bar" style="padding-left: 45px;"><div class="tools" style="padding: 3px; font-weight: bold; font-stretch: normal; font-size: 9px; line-height: normal; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; color: black; border-left-width: 3px; border-left-style: solid; border-left-color: rgb(108, 226, 108); margin: 0px; background-color: rgb(248, 248, 248);">Java代码  <a target=_blank href="http://xiaogui9317170.iteye.com/blog/283526" title="收藏这段代码" style="text-decoration: none; border: none; padding: 1px; margin: 0px 10px 0px 0px; font-size: 9px; color: rgb(0, 102, 153); display: inline-block; width: 16px; height: 16px; text-indent: -2000px; background-image: none; background-attachment: initial; background-color: inherit; background-size: initial; background-origin: initial; background-clip: initial; background-position: 0% 0%; background-repeat: no-repeat;"><img class="star" src="http://xiaogui9317170.iteye.com/images/icon_star.png" alt="收藏代码" style="border: 0px;" /></a></div></div><ol start="1" class="dp-j" style="margin: 0px 0px 1px; padding: 2px 0px; border: 1px solid rgb(209, 215, 220); list-style-position: initial; list-style-image: initial; color: rgb(43, 145, 175); font-size: 1em; line-height: 1.4em;"><li style="margin: 0px 0px 0px 38px; padding: 0px 0px 0px 10px; border-style: none none none solid; border-left-width: 1px; border-left-color: rgb(209, 215, 220); list-style: decimal-leading-zero outside; color: rgb(92, 92, 92); line-height: 18px; font-size: 1em; background-color: rgb(250, 250, 250);"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;"><span class="annotation" style="margin: 0px; padding: 0px; border: none; color: rgb(100, 100, 100); background-color: inherit;">@OneToOne</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">(cascade = CascadeType.ALL)   </span></span></li><li style="margin: 0px 0px 0px 38px; padding: 0px 0px 0px 10px; border-style: none none none solid; border-left-width: 1px; border-left-color: rgb(209, 215, 220); list-style: decimal-leading-zero outside; color: rgb(92, 92, 92); line-height: 18px; font-size: 1em; background-color: rgb(250, 250, 250);"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;"><span class="annotation" style="margin: 0px; padding: 0px; border: none; color: rgb(100, 100, 100); background-color: inherit;">@PrimaryKeyJoinColumn</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">   </span></span></li></ol></div><br style="color: rgb(85, 85, 85); font-family: 'microsoft yahei'; font-size: 15px; line-height: 35px;" /><br style="color: rgb(85, 85, 85); font-family: 'microsoft yahei'; font-size: 15px; line-height: 35px;" /><span style="color: rgb(85, 85, 85); font-family: 'microsoft yahei'; font-size: 15px; line-height: 35px;">例如 </span><br style="color: rgb(85, 85, 85); font-family: 'microsoft yahei'; font-size: 15px; line-height: 35px;" /><div class="dp-highlighter" id="" style="font-family: Monaco, 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', Consolas, 'Courier New', monospace; width: 659px; overflow: auto; padding: 1px; margin-left: 9px; border-color: rgb(204, 204, 204); color: rgb(85, 85, 85); line-height: 35px; word-break: break-all; word-wrap: break-word; margin-top: 18px !important; margin-right: 0px !important; margin-bottom: 18px !important; background-color: transparent;"><div class="bar" style="padding-left: 45px;"><div class="tools" style="padding: 3px; font-weight: bold; font-stretch: normal; font-size: 9px; line-height: normal; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; color: black; border-left-width: 3px; border-left-style: solid; border-left-color: rgb(108, 226, 108); margin: 0px; background-color: rgb(248, 248, 248);">Java代码  <a target=_blank href="http://xiaogui9317170.iteye.com/blog/283526" title="收藏这段代码" style="text-decoration: none; border: none; padding: 1px; margin: 0px 10px 0px 0px; font-size: 9px; color: rgb(0, 102, 153); display: inline-block; width: 16px; height: 16px; text-indent: -2000px; background-image: none; background-attachment: initial; background-color: inherit; background-size: initial; background-origin: initial; background-clip: initial; background-position: 0% 0%; background-repeat: no-repeat;"><img class="star" src="http://xiaogui9317170.iteye.com/images/icon_star.png" alt="收藏代码" style="border: 0px;" /></a></div></div><ol start="1" class="dp-j" style="margin: 0px 0px 1px; padding: 2px 0px; border: 1px solid rgb(209, 215, 220); list-style-position: initial; list-style-image: initial; color: rgb(43, 145, 175); font-size: 1em; line-height: 1.4em;"><li style="margin: 0px 0px 0px 38px; padding: 0px 0px 0px 10px; border-style: none none none solid; border-left-width: 1px; border-left-color: rgb(209, 215, 220); list-style: decimal-leading-zero outside; color: rgb(92, 92, 92); line-height: 18px; font-size: 1em; background-color: rgb(250, 250, 250);"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;"><span class="annotation" style="margin: 0px; padding: 0px; border: none; color: rgb(100, 100, 100); background-color: inherit;">@Entity</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">  </span></span></li><li style="margin: 0px 0px 0px 38px; padding: 0px 0px 0px 10px; border-style: none none none solid; border-left-width: 1px; border-left-color: rgb(209, 215, 220); list-style: decimal-leading-zero outside; color: rgb(92, 92, 92); line-height: 18px; font-size: 1em; background-color: rgb(250, 250, 250);"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;"><span class="keyword" style="margin: 0px; padding: 0px; border: none; color: rgb(127, 0, 85); font-weight: bold; background-color: inherit;">public</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;"> </span><span class="keyword" style="margin: 0px; padding: 0px; border: none; color: rgb(127, 0, 85); font-weight: bold; background-color: inherit;">class</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;"> Employee {  </span></span></li><li style="margin: 0px 0px 0px 38px; padding: 0px 0px 0px 10px; border-style: none none none solid; border-left-width: 1px; border-left-color: rgb(209, 215, 220); list-style: decimal-leading-zero outside; color: rgb(92, 92, 92); line-height: 18px; font-size: 1em; background-color: rgb(250, 250, 250);"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;">  <span class="annotation" style="margin: 0px; padding: 0px; border: none; color: rgb(100, 100, 100); background-color: inherit;">@Id</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;"> Integer id;  </span></span></li><li style="margin: 0px 0px 0px 38px; padding: 0px 0px 0px 10px; border-style: none none none solid; border-left-width: 1px; border-left-color: rgb(209, 215, 220); list-style: decimal-leading-zero outside; color: rgb(92, 92, 92); line-height: 18px; font-size: 1em; background-color: rgb(250, 250, 250);"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;">      </span></li><li style="margin: 0px 0px 0px 38px; padding: 0px 0px 0px 10px; border-style: none none none solid; border-left-width: 1px; border-left-color: rgb(209, 215, 220); list-style: decimal-leading-zero outside; color: rgb(92, 92, 92); line-height: 18px; font-size: 1em; background-color: rgb(250, 250, 250);"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;">  <span class="annotation" style="margin: 0px; padding: 0px; border: none; color: rgb(100, 100, 100); background-color: inherit;">@OneToOne</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;"> </span><span class="annotation" style="margin: 0px; padding: 0px; border: none; color: rgb(100, 100, 100); background-color: inherit;">@PrimaryKeyJoinColumn</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">  </span></span></li><li style="margin: 0px 0px 0px 38px; padding: 0px 0px 0px 10px; border-style: none none none solid; border-left-width: 1px; border-left-color: rgb(209, 215, 220); list-style: decimal-leading-zero outside; color: rgb(92, 92, 92); line-height: 18px; font-size: 1em; background-color: rgb(250, 250, 250);"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;">  EmployeeInfo info;  </span></li><li style="margin: 0px 0px 0px 38px; padding: 0px 0px 0px 10px; border-style: none none none solid; border-left-width: 1px; border-left-color: rgb(209, 215, 220); list-style: decimal-leading-zero outside; color: rgb(92, 92, 92); line-height: 18px; font-size: 1em; background-color: rgb(250, 250, 250);"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;">  ...  </span></li><li style="margin: 0px 0px 0px 38px; padding: 0px 0px 0px 10px; border-style: none none none solid; border-left-width: 1px; border-left-color: rgb(209, 215, 220); list-style: decimal-leading-zero outside; color: rgb(92, 92, 92); line-height: 18px; font-size: 1em; background-color: rgb(250, 250, 250);"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;">}  </span></li></ol></div><br style="color: rgb(85, 85, 85); font-family: 'microsoft yahei'; font-size: 15px; line-height: 35px;" /><br style="color: rgb(85, 85, 85); font-family: 'microsoft yahei'; font-size: 15px; line-height: 35px;" /><span style="color: rgb(85, 85, 85); font-family: 'microsoft yahei'; font-size: 15px; line-height: 35px;">应该为 </span><br style="color: rgb(85, 85, 85); font-family: 'microsoft yahei'; font-size: 15px; line-height: 35px;" /><div class="dp-highlighter" id="" style="font-family: Monaco, 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', Consolas, 'Courier New', monospace; width: 659px; overflow: auto; padding: 1px; margin-left: 9px; border-color: rgb(204, 204, 204); color: rgb(85, 85, 85); line-height: 35px; word-break: break-all; word-wrap: break-word; margin-top: 18px !important; margin-right: 0px !important; margin-bottom: 18px !important; background-color: transparent;"><div class="bar" style="padding-left: 45px;"><div class="tools" style="padding: 3px; font-weight: bold; font-stretch: normal; font-size: 9px; line-height: normal; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; color: black; border-left-width: 3px; border-left-style: solid; border-left-color: rgb(108, 226, 108); margin: 0px; background-color: rgb(248, 248, 248);">Java代码  <a target=_blank href="http://xiaogui9317170.iteye.com/blog/283526" title="收藏这段代码" style="text-decoration: none; border: none; padding: 1px; margin: 0px 10px 0px 0px; font-size: 9px; color: rgb(0, 102, 153); display: inline-block; width: 16px; height: 16px; text-indent: -2000px; background-image: none; background-attachment: initial; background-color: inherit; background-size: initial; background-origin: initial; background-clip: initial; background-position: 0% 0%; background-repeat: no-repeat;"><img class="star" src="http://xiaogui9317170.iteye.com/images/icon_star.png" alt="收藏代码" style="border: 0px;" /></a></div></div><ol start="1" class="dp-j" style="margin: 0px 0px 1px; padding: 2px 0px; border: 1px solid rgb(209, 215, 220); list-style-position: initial; list-style-image: initial; color: rgb(43, 145, 175); font-size: 1em; line-height: 1.4em;"><li style="margin: 0px 0px 0px 38px; padding: 0px 0px 0px 10px; border-style: none none none solid; border-left-width: 1px; border-left-color: rgb(209, 215, 220); list-style: decimal-leading-zero outside; color: rgb(92, 92, 92); line-height: 18px; font-size: 1em; background-color: rgb(250, 250, 250);"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;"><span class="annotation" style="margin: 0px; padding: 0px; border: none; color: rgb(100, 100, 100); background-color: inherit;">@Entity</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">  </span></span></li><li style="margin: 0px 0px 0px 38px; padding: 0px 0px 0px 10px; border-style: none none none solid; border-left-width: 1px; border-left-color: rgb(209, 215, 220); list-style: decimal-leading-zero outside; color: rgb(92, 92, 92); line-height: 18px; font-size: 1em; background-color: rgb(250, 250, 250);"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;"><span class="keyword" style="margin: 0px; padding: 0px; border: none; color: rgb(127, 0, 85); font-weight: bold; background-color: inherit;">public</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;"> </span><span class="keyword" style="margin: 0px; padding: 0px; border: none; color: rgb(127, 0, 85); font-weight: bold; background-color: inherit;">class</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;"> Employee {  </span></span></li><li style="margin: 0px 0px 0px 38px; padding: 0px 0px 0px 10px; border-style: none none none solid; border-left-width: 1px; border-left-color: rgb(209, 215, 220); list-style: decimal-leading-zero outside; color: rgb(92, 92, 92); line-height: 18px; font-size: 1em; background-color: rgb(250, 250, 250);"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;">  <span class="annotation" style="margin: 0px; padding: 0px; border: none; color: rgb(100, 100, 100); background-color: inherit;">@Id</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">   </span></span></li><li style="margin: 0px 0px 0px 38px; padding: 0px 0px 0px 10px; border-style: none none none solid; border-left-width: 1px; border-left-color: rgb(209, 215, 220); list-style: decimal-leading-zero outside; color: rgb(92, 92, 92); line-height: 18px; font-size: 1em; background-color: rgb(250, 250, 250);"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;">  <span class="annotation" style="margin: 0px; padding: 0px; border: none; color: rgb(100, 100, 100); background-color: inherit;">@GeneratedValue</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">(generator = </span><span class="string" style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit;">"idGenerator"</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">)  </span></span></li><li style="margin: 0px 0px 0px 38px; padding: 0px 0px 0px 10px; border-style: none none none solid; border-left-width: 1px; border-left-color: rgb(209, 215, 220); list-style: decimal-leading-zero outside; color: rgb(92, 92, 92); line-height: 18px; font-size: 1em; background-color: rgb(250, 250, 250);"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;">  <span class="annotation" style="margin: 0px; padding: 0px; border: none; color: rgb(100, 100, 100); background-color: inherit;">@GenericGenerator</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">(name = </span><span class="string" style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit;">"idGenerator"</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">, strategy = </span><span class="string" style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit;">"foreign"</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">,   </span></span></li><li style="margin: 0px 0px 0px 38px; padding: 0px 0px 0px 10px; border-style: none none none solid; border-left-width: 1px; border-left-color: rgb(209, 215, 220); list-style: decimal-leading-zero outside; color: rgb(92, 92, 92); line-height: 18px; font-size: 1em; background-color: rgb(250, 250, 250);"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;">         parameters = { <span class="annotation" style="margin: 0px; padding: 0px; border: none; color: rgb(100, 100, 100); background-color: inherit;">@Parameter</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">(name = </span><span class="string" style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit;">"property"</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">, value = </span><span class="string" style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit;">"info"</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">) })   </span></span></li><li style="margin: 0px 0px 0px 38px; padding: 0px 0px 0px 10px; border-style: none none none solid; border-left-width: 1px; border-left-color: rgb(209, 215, 220); list-style: decimal-leading-zero outside; color: rgb(92, 92, 92); line-height: 18px; font-size: 1em; background-color: rgb(250, 250, 250);"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;">  Integer id;  </span></li><li style="margin: 0px 0px 0px 38px; padding: 0px 0px 0px 10px; border-style: none none none solid; border-left-width: 1px; border-left-color: rgb(209, 215, 220); list-style: decimal-leading-zero outside; color: rgb(92, 92, 92); line-height: 18px; font-size: 1em; background-color: rgb(250, 250, 250);"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;">      </span></li><li style="margin: 0px 0px 0px 38px; padding: 0px 0px 0px 10px; border-style: none none none solid; border-left-width: 1px; border-left-color: rgb(209, 215, 220); list-style: decimal-leading-zero outside; color: rgb(92, 92, 92); line-height: 18px; font-size: 1em; background-color: rgb(250, 250, 250);"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;">  <span class="annotation" style="margin: 0px; padding: 0px; border: none; color: rgb(100, 100, 100); background-color: inherit;">@OneToOne</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">  </span></span></li><li style="margin: 0px 0px 0px 38px; padding: 0px 0px 0px 10px; border-style: none none none solid; border-left-width: 1px; border-left-color: rgb(209, 215, 220); list-style: decimal-leading-zero outside; color: rgb(92, 92, 92); line-height: 18px; font-size: 1em; background-color: rgb(250, 250, 250);"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;">  EmployeeInfo info;  </span></li><li style="margin: 0px 0px 0px 38px; padding: 0px 0px 0px 10px; border-style: none none none solid; border-left-width: 1px; border-left-color: rgb(209, 215, 220); list-style: decimal-leading-zero outside; color: rgb(92, 92, 92); line-height: 18px; font-size: 1em; background-color: rgb(250, 250, 250);"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;">  ...  </span></li><li style="margin: 0px 0px 0px 38px; padding: 0px 0px 0px 10px; border-style: none none none solid; border-left-width: 1px; border-left-color: rgb(209, 215, 220); list-style: decimal-leading-zero outside; color: rgb(92, 92, 92); line-height: 18px; font-size: 1em; background-color: rgb(250, 250, 250);"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;">}  </span></li></ol></div><br style="color: rgb(85, 85, 85); font-family: 'microsoft yahei'; font-size: 15px; line-height: 35px;" /><br style="color: rgb(85, 85, 85); font-family: 'microsoft yahei'; font-size: 15px; line-height: 35px;" /><span style="color: rgb(85, 85, 85); font-family: 'microsoft yahei'; font-size: 15px; line-height: 35px;">11、guid </span><br style="color: rgb(85, 85, 85); font-family: 'microsoft yahei'; font-size: 15px; line-height: 35px;" /><div class="dp-highlighter" id="" style="font-family: Monaco, 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', Consolas, 'Courier New', monospace; width: 659px; overflow: auto; padding: 1px; margin-left: 9px; border-color: rgb(204, 204, 204); color: rgb(85, 85, 85); line-height: 35px; word-break: break-all; word-wrap: break-word; margin-top: 18px !important; margin-right: 0px !important; margin-bottom: 18px !important; background-color: transparent;"><div class="bar" style="padding-left: 45px;"><div class="tools" style="padding: 3px; font-weight: bold; font-stretch: normal; font-size: 9px; line-height: normal; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; color: black; border-left-width: 3px; border-left-style: solid; border-left-color: rgb(108, 226, 108); margin: 0px; background-color: rgb(248, 248, 248);">Java代码  <a target=_blank href="http://xiaogui9317170.iteye.com/blog/283526" title="收藏这段代码" style="text-decoration: none; border: none; padding: 1px; margin: 0px 10px 0px 0px; font-size: 9px; color: rgb(0, 102, 153); display: inline-block; width: 16px; height: 16px; text-indent: -2000px; background-image: none; background-attachment: initial; background-color: inherit; background-size: initial; background-origin: initial; background-clip: initial; background-position: 0% 0%; background-repeat: no-repeat;"><img class="star" src="http://xiaogui9317170.iteye.com/images/icon_star.png" alt="收藏代码" style="border: 0px;" /></a></div></div><ol start="1" class="dp-j" style="margin: 0px 0px 1px; padding: 2px 0px; border: 1px solid rgb(209, 215, 220); list-style-position: initial; list-style-image: initial; color: rgb(43, 145, 175); font-size: 1em; line-height: 1.4em;"><li style="margin: 0px 0px 0px 38px; padding: 0px 0px 0px 10px; border-style: none none none solid; border-left-width: 1px; border-left-color: rgb(209, 215, 220); list-style: decimal-leading-zero outside; color: rgb(92, 92, 92); line-height: 18px; font-size: 1em; background-color: rgb(250, 250, 250);"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;"><span class="annotation" style="margin: 0px; padding: 0px; border: none; color: rgb(100, 100, 100); background-color: inherit;">@GeneratedValue</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">(generator = </span><span class="string" style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit;">"paymentableGenerator"</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">)    </span></span></li><li style="margin: 0px 0px 0px 38px; padding: 0px 0px 0px 10px; border-style: none none none solid; border-left-width: 1px; border-left-color: rgb(209, 215, 220); list-style: decimal-leading-zero outside; color: rgb(92, 92, 92); line-height: 18px; font-size: 1em; background-color: rgb(250, 250, 250);"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;"><span class="annotation" style="margin: 0px; padding: 0px; border: none; color: rgb(100, 100, 100); background-color: inherit;">@GenericGenerator</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">(name = </span><span class="string" style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit;">"paymentableGenerator"</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">, strategy = </span><span class="string" style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit;">"guid"</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">)   </span></span></li></ol></div><br style="color: rgb(85, 85, 85); font-family: 'microsoft yahei'; font-size: 15px; line-height: 35px;" /><span style="color: rgb(85, 85, 85); font-family: 'microsoft yahei'; font-size: 15px; line-height: 35px;">12、uuid.hex </span><br style="color: rgb(85, 85, 85); font-family: 'microsoft yahei'; font-size: 15px; line-height: 35px;" /><div class="dp-highlighter" id="" style="font-family: Monaco, 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', Consolas, 'Courier New', monospace; width: 659px; overflow: auto; padding: 1px; margin-left: 9px; border-color: rgb(204, 204, 204); color: rgb(85, 85, 85); line-height: 35px; word-break: break-all; word-wrap: break-word; margin-top: 18px !important; margin-right: 0px !important; margin-bottom: 18px !important; background-color: transparent;"><div class="bar" style="padding-left: 45px;"><div class="tools" style="padding: 3px; font-weight: bold; font-stretch: normal; font-size: 9px; line-height: normal; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; color: black; border-left-width: 3px; border-left-style: solid; border-left-color: rgb(108, 226, 108); margin: 0px; background-color: rgb(248, 248, 248);">Java代码  <a target=_blank href="http://xiaogui9317170.iteye.com/blog/283526" title="收藏这段代码" style="text-decoration: none; border: none; padding: 1px; margin: 0px 10px 0px 0px; font-size: 9px; color: rgb(0, 102, 153); display: inline-block; width: 16px; height: 16px; text-indent: -2000px; background-image: none; background-attachment: initial; background-color: inherit; background-size: initial; background-origin: initial; background-clip: initial; background-position: 0% 0%; background-repeat: no-repeat;"><img class="star" src="http://xiaogui9317170.iteye.com/images/icon_star.png" alt="收藏代码" style="border: 0px;" /></a></div></div><ol start="1" class="dp-j" style="margin: 0px 0px 1px; padding: 2px 0px; border: 1px solid rgb(209, 215, 220); list-style-position: initial; list-style-image: initial; color: rgb(43, 145, 175); font-size: 1em; line-height: 1.4em;"><li style="margin: 0px 0px 0px 38px; padding: 0px 0px 0px 10px; border-style: none none none solid; border-left-width: 1px; border-left-color: rgb(209, 215, 220); list-style: decimal-leading-zero outside; color: rgb(92, 92, 92); line-height: 18px; font-size: 1em; background-color: rgb(250, 250, 250);"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;"><span class="annotation" style="margin: 0px; padding: 0px; border: none; color: rgb(100, 100, 100); background-color: inherit;">@GeneratedValue</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">(generator = </span><span class="string" style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit;">"paymentableGenerator"</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">)    </span></span></li><li style="margin: 0px 0px 0px 38px; padding: 0px 0px 0px 10px; border-style: none none none solid; border-left-width: 1px; border-left-color: rgb(209, 215, 220); list-style: decimal-leading-zero outside; color: rgb(92, 92, 92); line-height: 18px; font-size: 1em; background-color: rgb(250, 250, 250);"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;"><span class="annotation" style="margin: 0px; padding: 0px; border: none; color: rgb(100, 100, 100); background-color: inherit;">@GenericGenerator</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">(name = </span><span class="string" style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit;">"paymentableGenerator"</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">, strategy = </span><span class="string" style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit;">"uuid.hex"</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">)   </span></span></li></ol></div><br style="color: rgb(85, 85, 85); font-family: 'microsoft yahei'; font-size: 15px; line-height: 35px;" /><span style="color: rgb(85, 85, 85); font-family: 'microsoft yahei'; font-size: 15px; line-height: 35px;">13、sequence-identity </span><br style="color: rgb(85, 85, 85); font-family: 'microsoft yahei'; font-size: 15px; line-height: 35px;" /><div class="dp-highlighter" id="" style="font-family: Monaco, 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', Consolas, 'Courier New', monospace; width: 659px; overflow: auto; padding: 1px; margin-left: 9px; border-color: rgb(204, 204, 204); color: rgb(85, 85, 85); line-height: 35px; word-break: break-all; word-wrap: break-word; margin-top: 18px !important; margin-right: 0px !important; margin-bottom: 18px !important; background-color: transparent;"><div class="bar" style="padding-left: 45px;"><div class="tools" style="padding: 3px; font-weight: bold; font-stretch: normal; font-size: 9px; line-height: normal; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; color: black; border-left-width: 3px; border-left-style: solid; border-left-color: rgb(108, 226, 108); margin: 0px; background-color: rgb(248, 248, 248);">Java代码  <a target=_blank href="http://xiaogui9317170.iteye.com/blog/283526" title="收藏这段代码" style="text-decoration: none; border: none; padding: 1px; margin: 0px 10px 0px 0px; font-size: 9px; color: rgb(0, 102, 153); display: inline-block; width: 16px; height: 16px; text-indent: -2000px; background-image: none; background-attachment: initial; background-color: inherit; background-size: initial; background-origin: initial; background-clip: initial; background-position: 0% 0%; background-repeat: no-repeat;"><img class="star" src="http://xiaogui9317170.iteye.com/images/icon_star.png" alt="收藏代码" style="border: 0px;" /></a></div></div><ol start="1" class="dp-j" style="margin: 0px 0px 1px; padding: 2px 0px; border: 1px solid rgb(209, 215, 220); list-style-position: initial; list-style-image: initial; color: rgb(43, 145, 175); font-size: 1em; line-height: 1.4em;"><li style="margin: 0px 0px 0px 38px; padding: 0px 0px 0px 10px; border-style: none none none solid; border-left-width: 1px; border-left-color: rgb(209, 215, 220); list-style: decimal-leading-zero outside; color: rgb(92, 92, 92); line-height: 18px; font-size: 1em; background-color: rgb(250, 250, 250);"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;"><span class="annotation" style="margin: 0px; padding: 0px; border: none; color: rgb(100, 100, 100); background-color: inherit;">@GeneratedValue</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">(generator = </span><span class="string" style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit;">"paymentableGenerator"</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">)  </span></span></li><li style="margin: 0px 0px 0px 38px; padding: 0px 0px 0px 10px; border-style: none none none solid; border-left-width: 1px; border-left-color: rgb(209, 215, 220); list-style: decimal-leading-zero outside; color: rgb(92, 92, 92); line-height: 18px; font-size: 1em; background-color: rgb(250, 250, 250);"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;"><span class="annotation" style="margin: 0px; padding: 0px; border: none; color: rgb(100, 100, 100); background-color: inherit;">@GenericGenerator</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">(name = </span><span class="string" style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit;">"paymentableGenerator"</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">, strategy = </span><span class="string" style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit;">"sequence-identity"</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">,   </span></span></li><li style="margin: 0px 0px 0px 38px; padding: 0px 0px 0px 10px; border-style: none none none solid; border-left-width: 1px; border-left-color: rgb(209, 215, 220); list-style: decimal-leading-zero outside; color: rgb(92, 92, 92); line-height: 18px; font-size: 1em; background-color: rgb(250, 250, 250);"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;">         parameters = { <span class="annotation" style="margin: 0px; padding: 0px; border: none; color: rgb(100, 100, 100); background-color: inherit;">@Parameter</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">(name = </span><span class="string" style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit;">"sequence"</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">, value = </span><span class="string" style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit;">"seq_payablemoney"</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">) })  </span></span></li></ol></div><br style="color: rgb(85, 85, 85); font-family: 'microsoft yahei'; font-size: 15px; line-height: 35px;" /><br style="color: rgb(85, 85, 85); font-family: 'microsoft yahei'; font-size: 15px; line-height: 35px;" /><span style="color: rgb(85, 85, 85); font-family: 'microsoft yahei'; font-size: 15px; line-height: 35px;">四、通过@GenericGenerator自定义主键生成策略 </span><br style="color: rgb(85, 85, 85); font-family: 'microsoft yahei'; font-size: 15px; line-height: 35px;" /><span style="color: rgb(85, 85, 85); font-family: 'microsoft yahei'; font-size: 15px; line-height: 35px;">如果实际应用中,主键策略为程序指定了就用程序指定的主键(assigned),没有指定就从sequence中取。 </span><br style="color: rgb(85, 85, 85); font-family: 'microsoft yahei'; font-size: 15px; line-height: 35px;" /><span style="color: rgb(85, 85, 85); font-family: 'microsoft yahei'; font-size: 15px; line-height: 35px;">明显上面所讨论的策略都不满足,只好自己扩展了,集成assigned和sequence两种策略。 </span><br style="color: rgb(85, 85, 85); font-family: 'microsoft yahei'; font-size: 15px; line-height: 35px;" /><br style="color: rgb(85, 85, 85); font-family: 'microsoft yahei'; font-size: 15px; line-height: 35px;" /><div class="dp-highlighter" id="" style="font-family: Monaco, 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', Consolas, 'Courier New', monospace; width: 659px; overflow: auto; padding: 1px; margin-left: 9px; border-color: rgb(204, 204, 204); color: rgb(85, 85, 85); line-height: 35px; word-break: break-all; word-wrap: break-word; margin-top: 18px !important; margin-right: 0px !important; margin-bottom: 18px !important; background-color: transparent;"><div class="bar" style="padding-left: 45px;"><div class="tools" style="padding: 3px; font-weight: bold; font-stretch: normal; font-size: 9px; line-height: normal; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; color: black; border-left-width: 3px; border-left-style: solid; border-left-color: rgb(108, 226, 108); margin: 0px; background-color: rgb(248, 248, 248);">Java代码  <a target=_blank href="http://xiaogui9317170.iteye.com/blog/283526" title="收藏这段代码" style="text-decoration: none; border: none; padding: 1px; margin: 0px 10px 0px 0px; font-size: 9px; color: rgb(0, 102, 153); display: inline-block; width: 16px; height: 16px; text-indent: -2000px; background-image: none; background-attachment: initial; background-color: inherit; background-size: initial; background-origin: initial; background-clip: initial; background-position: 0% 0%; background-repeat: no-repeat;"><img class="star" src="http://xiaogui9317170.iteye.com/images/icon_star.png" alt="收藏代码" style="border: 0px;" /></a></div></div><ol start="1" class="dp-j" style="margin: 0px 0px 1px; padding: 2px 0px; border: 1px solid rgb(209, 215, 220); list-style-position: initial; list-style-image: initial; color: rgb(43, 145, 175); font-size: 1em; line-height: 1.4em;"><li style="margin: 0px 0px 0px 38px; padding: 0px 0px 0px 10px; border-style: none none none solid; border-left-width: 1px; border-left-color: rgb(209, 215, 220); list-style: decimal-leading-zero outside; color: rgb(92, 92, 92); line-height: 18px; font-size: 1em; background-color: rgb(250, 250, 250);"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;"><span class="keyword" style="margin: 0px; padding: 0px; border: none; color: rgb(127, 0, 85); font-weight: bold; background-color: inherit;">public</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;"> </span><span class="keyword" style="margin: 0px; padding: 0px; border: none; color: rgb(127, 0, 85); font-weight: bold; background-color: inherit;">class</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;"> AssignedSequenceGenerator </span><span class="keyword" style="margin: 0px; padding: 0px; border: none; color: rgb(127, 0, 85); font-weight: bold; background-color: inherit;">extends</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;"> SequenceGenerator </span><span class="keyword" style="margin: 0px; padding: 0px; border: none; color: rgb(127, 0, 85); font-weight: bold; background-color: inherit;">implements</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">   </span></span></li><li style="margin: 0px 0px 0px 38px; padding: 0px 0px 0px 10px; border-style: none none none solid; border-left-width: 1px; border-left-color: rgb(209, 215, 220); list-style: decimal-leading-zero outside; color: rgb(92, 92, 92); line-height: 18px; font-size: 1em; background-color: rgb(250, 250, 250);"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;"> PersistentIdentifierGenerator, Configurable {  </span></li><li style="margin: 0px 0px 0px 38px; padding: 0px 0px 0px 10px; border-style: none none none solid; border-left-width: 1px; border-left-color: rgb(209, 215, 220); list-style: decimal-leading-zero outside; color: rgb(92, 92, 92); line-height: 18px; font-size: 1em; background-color: rgb(250, 250, 250);"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;"> <span class="keyword" style="margin: 0px; padding: 0px; border: none; color: rgb(127, 0, 85); font-weight: bold; background-color: inherit;">private</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;"> String entityName;  </span></span></li><li style="margin: 0px 0px 0px 38px; padding: 0px 0px 0px 10px; border-style: none none none solid; border-left-width: 1px; border-left-color: rgb(209, 215, 220); list-style: decimal-leading-zero outside; color: rgb(92, 92, 92); line-height: 18px; font-size: 1em; background-color: rgb(250, 250, 250);"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;">    </span></li><li style="margin: 0px 0px 0px 38px; padding: 0px 0px 0px 10px; border-style: none none none solid; border-left-width: 1px; border-left-color: rgb(209, 215, 220); list-style: decimal-leading-zero outside; color: rgb(92, 92, 92); line-height: 18px; font-size: 1em; background-color: rgb(250, 250, 250);"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;"> <span class="keyword" style="margin: 0px; padding: 0px; border: none; color: rgb(127, 0, 85); font-weight: bold; background-color: inherit;">public</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;"> </span><span class="keyword" style="margin: 0px; padding: 0px; border: none; color: rgb(127, 0, 85); font-weight: bold; background-color: inherit;">void</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;"> configure(Type type, Properties params, Dialect dialect) </span><span class="keyword" style="margin: 0px; padding: 0px; border: none; color: rgb(127, 0, 85); font-weight: bold; background-color: inherit;">throws</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;"> MappingException {  </span></span></li><li style="margin: 0px 0px 0px 38px; padding: 0px 0px 0px 10px; border-style: none none none solid; border-left-width: 1px; border-left-color: rgb(209, 215, 220); list-style: decimal-leading-zero outside; color: rgb(92, 92, 92); line-height: 18px; font-size: 1em; background-color: rgb(250, 250, 250);"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;">  entityName = params.getProperty(ENTITY_NAME);  </span></li><li style="margin: 0px 0px 0px 38px; padding: 0px 0px 0px 10px; border-style: none none none solid; border-left-width: 1px; border-left-color: rgb(209, 215, 220); list-style: decimal-leading-zero outside; color: rgb(92, 92, 92); line-height: 18px; font-size: 1em; background-color: rgb(250, 250, 250);"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;">  <span class="keyword" style="margin: 0px; padding: 0px; border: none; color: rgb(127, 0, 85); font-weight: bold; background-color: inherit;">if</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;"> (entityName==</span><span class="keyword" style="margin: 0px; padding: 0px; border: none; color: rgb(127, 0, 85); font-weight: bold; background-color: inherit;">null</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">) {  </span></span></li><li style="margin: 0px 0px 0px 38px; padding: 0px 0px 0px 10px; border-style: none none none solid; border-left-width: 1px; border-left-color: rgb(209, 215, 220); list-style: decimal-leading-zero outside; color: rgb(92, 92, 92); line-height: 18px; font-size: 1em; background-color: rgb(250, 250, 250);"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;">   <span class="keyword" style="margin: 0px; padding: 0px; border: none; color: rgb(127, 0, 85); font-weight: bold; background-color: inherit;">throw</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;"> </span><span class="keyword" style="margin: 0px; padding: 0px; border: none; color: rgb(127, 0, 85); font-weight: bold; background-color: inherit;">new</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;"> MappingException(</span><span class="string" style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit;">"no entity name"</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">);  </span></span></li><li style="margin: 0px 0px 0px 38px; padding: 0px 0px 0px 10px; border-style: none none none solid; border-left-width: 1px; border-left-color: rgb(209, 215, 220); list-style: decimal-leading-zero outside; color: rgb(92, 92, 92); line-height: 18px; font-size: 1em; background-color: rgb(250, 250, 250);"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;">  }  </span></li><li style="margin: 0px 0px 0px 38px; padding: 0px 0px 0px 10px; border-style: none none none solid; border-left-width: 1px; border-left-color: rgb(209, 215, 220); list-style: decimal-leading-zero outside; color: rgb(92, 92, 92); line-height: 18px; font-size: 1em; background-color: rgb(250, 250, 250);"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;">    </span></li><li style="margin: 0px 0px 0px 38px; padding: 0px 0px 0px 10px; border-style: none none none solid; border-left-width: 1px; border-left-color: rgb(209, 215, 220); list-style: decimal-leading-zero outside; color: rgb(92, 92, 92); line-height: 18px; font-size: 1em; background-color: rgb(250, 250, 250);"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;">  <span class="keyword" style="margin: 0px; padding: 0px; border: none; color: rgb(127, 0, 85); font-weight: bold; background-color: inherit;">super</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">.configure(type, params, dialect);    </span></span></li><li style="margin: 0px 0px 0px 38px; padding: 0px 0px 0px 10px; border-style: none none none solid; border-left-width: 1px; border-left-color: rgb(209, 215, 220); list-style: decimal-leading-zero outside; color: rgb(92, 92, 92); line-height: 18px; font-size: 1em; background-color: rgb(250, 250, 250);"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;"> }  </span></li><li style="margin: 0px 0px 0px 38px; padding: 0px 0px 0px 10px; border-style: none none none solid; border-left-width: 1px; border-left-color: rgb(209, 215, 220); list-style: decimal-leading-zero outside; color: rgb(92, 92, 92); line-height: 18px; font-size: 1em; background-color: rgb(250, 250, 250);"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;">   </span></li><li style="margin: 0px 0px 0px 38px; padding: 0px 0px 0px 10px; border-style: none none none solid; border-left-width: 1px; border-left-color: rgb(209, 215, 220); list-style: decimal-leading-zero outside; color: rgb(92, 92, 92); line-height: 18px; font-size: 1em; background-color: rgb(250, 250, 250);"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;"> <span class="keyword" style="margin: 0px; padding: 0px; border: none; color: rgb(127, 0, 85); font-weight: bold; background-color: inherit;">public</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;"> Serializable generate(SessionImplementor session, Object obj)   </span></span></li><li style="margin: 0px 0px 0px 38px; padding: 0px 0px 0px 10px; border-style: none none none solid; border-left-width: 1px; border-left-color: rgb(209, 215, 220); list-style: decimal-leading-zero outside; color: rgb(92, 92, 92); line-height: 18px; font-size: 1em; background-color: rgb(250, 250, 250);"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;">  <span class="keyword" style="margin: 0px; padding: 0px; border: none; color: rgb(127, 0, 85); font-weight: bold; background-color: inherit;">throws</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;"> HibernateException {  </span></span></li><li style="margin: 0px 0px 0px 38px; padding: 0px 0px 0px 10px; border-style: none none none solid; border-left-width: 1px; border-left-color: rgb(209, 215, 220); list-style: decimal-leading-zero outside; color: rgb(92, 92, 92); line-height: 18px; font-size: 1em; background-color: rgb(250, 250, 250);"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;">    </span></li><li style="margin: 0px 0px 0px 38px; padding: 0px 0px 0px 10px; border-style: none none none solid; border-left-width: 1px; border-left-color: rgb(209, 215, 220); list-style: decimal-leading-zero outside; color: rgb(92, 92, 92); line-height: 18px; font-size: 1em; background-color: rgb(250, 250, 250);"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;">  Serializable id = session.getEntityPersister( entityName, obj )   </span></li><li style="margin: 0px 0px 0px 38px; padding: 0px 0px 0px 10px; border-style: none none none solid; border-left-width: 1px; border-left-color: rgb(209, 215, 220); list-style: decimal-leading-zero outside; color: rgb(92, 92, 92); line-height: 18px; font-size: 1em; background-color: rgb(250, 250, 250);"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;">    .getIdentifier( obj, session.getEntityMode() );  </span></li><li style="margin: 0px 0px 0px 38px; padding: 0px 0px 0px 10px; border-style: none none none solid; border-left-width: 1px; border-left-color: rgb(209, 215, 220); list-style: decimal-leading-zero outside; color: rgb(92, 92, 92); line-height: 18px; font-size: 1em; background-color: rgb(250, 250, 250);"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;">    </span></li><li style="margin: 0px 0px 0px 38px; padding: 0px 0px 0px 10px; border-style: none none none solid; border-left-width: 1px; border-left-color: rgb(209, 215, 220); list-style: decimal-leading-zero outside; color: rgb(92, 92, 92); line-height: 18px; font-size: 1em; background-color: rgb(250, 250, 250);"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;">  <span class="keyword" style="margin: 0px; padding: 0px; border: none; color: rgb(127, 0, 85); font-weight: bold; background-color: inherit;">if</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;"> (id==</span><span class="keyword" style="margin: 0px; padding: 0px; border: none; color: rgb(127, 0, 85); font-weight: bold; background-color: inherit;">null</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">) {  </span></span></li><li style="margin: 0px 0px 0px 38px; padding: 0px 0px 0px 10px; border-style: none none none solid; border-left-width: 1px; border-left-color: rgb(209, 215, 220); list-style: decimal-leading-zero outside; color: rgb(92, 92, 92); line-height: 18px; font-size: 1em; background-color: rgb(250, 250, 250);"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;">   id = <span class="keyword" style="margin: 0px; padding: 0px; border: none; color: rgb(127, 0, 85); font-weight: bold; background-color: inherit;">super</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">.generate(session, obj);  </span></span></li><li style="margin: 0px 0px 0px 38px; padding: 0px 0px 0px 10px; border-style: none none none solid; border-left-width: 1px; border-left-color: rgb(209, 215, 220); list-style: decimal-leading-zero outside; color: rgb(92, 92, 92); line-height: 18px; font-size: 1em; background-color: rgb(250, 250, 250);"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;">  }  </span></li><li style="margin: 0px 0px 0px 38px; padding: 0px 0px 0px 10px; border-style: none none none solid; border-left-width: 1px; border-left-color: rgb(209, 215, 220); list-style: decimal-leading-zero outside; color: rgb(92, 92, 92); line-height: 18px; font-size: 1em; background-color: rgb(250, 250, 250);"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;">    </span></li><li style="margin: 0px 0px 0px 38px; padding: 0px 0px 0px 10px; border-style: none none none solid; border-left-width: 1px; border-left-color: rgb(209, 215, 220); list-style: decimal-leading-zero outside; color: rgb(92, 92, 92); line-height: 18px; font-size: 1em; background-color: rgb(250, 250, 250);"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;">  <span class="keyword" style="margin: 0px; padding: 0px; border: none; color: rgb(127, 0, 85); font-weight: bold; background-color: inherit;">return</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;"> id;  </span></span></li><li style="margin: 0px 0px 0px 38px; padding: 0px 0px 0px 10px; border-style: none none none solid; border-left-width: 1px; border-left-color: rgb(209, 215, 220); list-style: decimal-leading-zero outside; color: rgb(92, 92, 92); line-height: 18px; font-size: 1em; background-color: rgb(250, 250, 250);"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;"> }  </span></li><li style="margin: 0px 0px 0px 38px; padding: 0px 0px 0px 10px; border-style: none none none solid; border-left-width: 1px; border-left-color: rgb(209, 215, 220); list-style: decimal-leading-zero outside; color: rgb(92, 92, 92); line-height: 18px; font-size: 1em; background-color: rgb(250, 250, 250);"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;">}  </span></li></ol></div><br style="color: rgb(85, 85, 85); font-family: 'microsoft yahei'; font-size: 15px; line-height: 35px;" /><br style="color: rgb(85, 85, 85); font-family: 'microsoft yahei'; font-size: 15px; line-height: 35px;" /><span style="color: rgb(85, 85, 85); font-family: 'microsoft yahei'; font-size: 15px; line-height: 35px;">实际应用中,定义同sequence。 </span><br style="color: rgb(85, 85, 85); font-family: 'microsoft yahei'; font-size: 15px; line-height: 35px;" /><div class="dp-highlighter" id="" style="font-family: Monaco, 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', Consolas, 'Courier New', monospace; width: 659px; overflow: auto; padding: 1px; margin-left: 9px; border-color: rgb(204, 204, 204); color: rgb(85, 85, 85); line-height: 35px; word-break: break-all; word-wrap: break-word; margin-top: 18px !important; margin-right: 0px !important; margin-bottom: 18px !important; background-color: transparent;"><div class="bar" style="padding-left: 45px;"><div class="tools" style="padding: 3px; font-weight: bold; font-stretch: normal; font-size: 9px; line-height: normal; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; color: black; border-left-width: 3px; border-left-style: solid; border-left-color: rgb(108, 226, 108); margin: 0px; background-color: rgb(248, 248, 248);">Java代码  <a target=_blank href="http://xiaogui9317170.iteye.com/blog/283526" title="收藏这段代码" style="text-decoration: none; border: none; padding: 1px; margin: 0px 10px 0px 0px; font-size: 9px; color: rgb(0, 102, 153); display: inline-block; width: 16px; height: 16px; text-indent: -2000px; background-image: none; background-attachment: initial; background-color: inherit; background-size: initial; background-origin: initial; background-clip: initial; background-position: 0% 0%; background-repeat: no-repeat;"><img class="star" src="http://xiaogui9317170.iteye.com/images/icon_star.png" alt="收藏代码" style="border: 0px;" /></a></div></div><ol start="1" class="dp-j" style="margin: 0px 0px 1px; padding: 2px 0px; border: 1px solid rgb(209, 215, 220); list-style-position: initial; list-style-image: initial; color: rgb(43, 145, 175); font-size: 1em; line-height: 1.4em;"><li style="margin: 0px 0px 0px 38px; padding: 0px 0px 0px 10px; border-style: none none none solid; border-left-width: 1px; border-left-color: rgb(209, 215, 220); list-style: decimal-leading-zero outside; color: rgb(92, 92, 92); line-height: 18px; font-size: 1em; background-color: rgb(250, 250, 250);"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;"><span class="annotation" style="margin: 0px; padding: 0px; border: none; color: rgb(100, 100, 100); background-color: inherit;">@GeneratedValue</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">(generator = </span><span class="string" style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit;">"paymentableGenerator"</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">)  </span></span></li><li style="margin: 0px 0px 0px 38px; padding: 0px 0px 0px 10px; border-style: none none none solid; border-left-width: 1px; border-left-color: rgb(209, 215, 220); list-style: decimal-leading-zero outside; color: rgb(92, 92, 92); line-height: 18px; font-size: 1em; background-color: rgb(250, 250, 250);"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;"><span class="annotation" style="margin: 0px; padding: 0px; border: none; color: rgb(100, 100, 100); background-color: inherit;">@GenericGenerator</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">(name = </span><span class="string" style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit;">"paymentableGenerator"</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">, strategy = </span><span class="string" style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit;">"AssignedSequenceGenerator"</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">,   </span></span></li><li style="margin: 0px 0px 0px 38px; padding: 0px 0px 0px 10px; border-style: none none none solid; border-left-width: 1px; border-left-color: rgb(209, 215, 220); list-style: decimal-leading-zero outside; color: rgb(92, 92, 92); line-height: 18px; font-size: 1em; background-color: rgb(250, 250, 250);"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;">     parameters = { <span class="annotation" style="margin: 0px; padding: 0px; border: none; color: rgb(100, 100, 100); background-color: inherit;">@Parameter</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">(name = </span><span class="string" style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit;">"sequence"</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">, value = </span><span class="string" style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit;">"seq_payablemoney"</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">) })  </span></span></li></ol><div><span style="color: rgb(43, 145, 175);"><span style="line-height: 16px;"></span></span></div><div><span style="color: rgb(43, 145, 175);"><span style="line-height: 16px;"></span></span></div><div><span style="color: rgb(43, 145, 175);"><span style="line-height: 16px;"></span></span></div><div><span style="color: rgb(43, 145, 175);"><span style="line-height: 16px;"><span style="color: rgb(73, 73, 73); font-family: Verdana, 宋体, sans-serif; line-height: 18px; background-color: rgb(224, 195, 161);"></span></span></span><p style="margin-top: 0pt; margin-bottom: 0pt; padding-top: 0px; padding-bottom: 0px; border: 0px; list-style-type: none; list-style-position: initial; word-wrap: normal; word-break: normal; line-height: 18px;"><span style="word-wrap: normal; word-break: normal; line-height: 21px; color: rgb(100, 100, 100); font-size: 10.5pt; font-family: 'Courier new';">四种数据库的支持情况如下:</span></p><p style="margin-top: 0pt; margin-bottom: 0pt; padding-top: 0px; padding-bottom: 0px; border: 0px; list-style-type: none; list-style-position: initial; word-wrap: normal; word-break: normal; line-height: 18px;"> <wbr></wbr></p><table style="margin: 0px; padding: 0pt 5.4pt; border-collapse: collapse;"><tbody><tr><td width="307" valign="top" style="margin: 0px; padding: 0pt 5.4pt; font-family: Verdana, 宋体, sans-serif; line-height: 18px; width: 230.4pt; border: 0.5pt solid rgb(0, 0, 0);"><p style="margin-top: 0pt; margin-bottom: 0pt; padding-top: 0px; padding-bottom: 0px; border: 0px; list-style-type: none; list-style-position: initial; word-wrap: normal; word-break: normal;"><span style="word-wrap: normal; word-break: normal; line-height: 21px; font-size: 10.5pt; font-family: 宋体;">数据库名称</span></p></td><td width="307" valign="top" style="margin: 0px; padding: 0pt 5.4pt; font-family: Verdana, 宋体, sans-serif; line-height: 18px; width: 230.4pt; border-style: solid solid solid none; border-right-width: 0.5pt; border-right-color: rgb(0, 0, 0); border-top-width: 0.5pt; border-top-color: rgb(0, 0, 0); border-bottom-width: 0.5pt; border-bottom-color: rgb(0, 0, 0);"><p style="margin-top: 0pt; margin-bottom: 0pt; padding-top: 0px; padding-bottom: 0px; border: 0px; list-style-type: none; list-style-position: initial; word-wrap: normal; word-break: normal;"><span style="word-wrap: normal; word-break: normal; line-height: 21px; font-size: 10.5pt; font-family: 宋体;">支持的</span><span style="word-wrap: normal; word-break: normal; line-height: 21px; font-size: 10.5pt; font-family: 宋体;">id<span style="word-wrap: normal; word-break: normal;">策略</span></span></p></td></tr><tr><td width="307" valign="top" style="margin: 0px; padding: 0pt 5.4pt; font-family: Verdana, 宋体, sans-serif; line-height: 18px; width: 230.4pt; border-left-width: 0.5pt; border-style: none solid solid; border-left-color: rgb(0, 0, 0); border-right-width: 0.5pt; border-right-color: rgb(0, 0, 0); border-bottom-width: 0.5pt; border-bottom-color: rgb(0, 0, 0);"><p style="margin-top: 0pt; margin-bottom: 0pt; padding-top: 0px; padding-bottom: 0px; border: 0px; list-style-type: none; list-style-position: initial; word-wrap: normal; word-break: normal;"><span style="word-wrap: normal; word-break: normal; line-height: 21px; font-size: 10.5pt; font-family: 宋体;">mysql</span></p></td><td width="307" valign="top" style="margin: 0px; padding: 0pt 5.4pt; font-family: Verdana, 宋体, sans-serif; line-height: 18px; width: 230.4pt; border-style: none solid solid none; border-right-width: 0.5pt; border-right-color: rgb(0, 0, 0); border-bottom-width: 0.5pt; border-bottom-color: rgb(0, 0, 0);"><p style="margin-top: 0pt; margin-bottom: 0pt; padding-top: 0px; padding-bottom: 0px; border: 0px; list-style-type: none; list-style-position: initial; word-wrap: normal; word-break: normal;"><span style="word-wrap: normal; word-break: normal; line-height: 21px; font-size: 10.5pt; font-family: 'Courier new';">GenerationType.</span><span style="word-wrap: normal; word-break: normal; line-height: 21px; color: rgb(0, 0, 192); font-size: 10.5pt; font-family: 'Courier new'; background-color: rgb(192, 192, 192);"><em>TABLE</em></span></p><p style="margin-top: 0pt; margin-bottom: 0pt; padding-top: 0px; padding-bottom: 0px; border: 0px; list-style-type: none; list-style-position: initial; word-wrap: normal; word-break: normal;"><span style="word-wrap: normal; word-break: normal; line-height: 21px; font-size: 10.5pt; font-family: 'Courier new';">GenerationType.</span><span style="word-wrap: normal; word-break: normal; line-height: 21px; color: rgb(0, 0, 192); font-size: 10.5pt; font-family: 'Courier new'; background-color: rgb(192, 192, 192);"><em>AUTO</em></span></p><p style="margin-top: 0pt; margin-bottom: 0pt; padding-top: 0px; padding-bottom: 0px; border: 0px; list-style-type: none; list-style-position: initial; word-wrap: normal; word-break: normal;"><span style="word-wrap: normal; word-break: normal; line-height: 21px; font-size: 10.5pt; font-family: 'Courier new';">GenerationType.</span><span style="word-wrap: normal; word-break: normal; line-height: 21px; color: rgb(0, 0, 192); font-size: 10.5pt; font-family: 'Courier new'; background-color: rgb(192, 192, 192);"><em>IDENTITY</em></span></p><p style="margin-top: 0pt; margin-bottom: 0pt; padding-top: 0px; padding-bottom: 0px; border: 0px; list-style-type: none; list-style-position: initial; word-wrap: normal; word-break: normal;"><span style="word-wrap: normal; word-break: normal; line-height: 21px; color: rgb(255, 0, 0); font-size: 10.5pt; font-family: 宋体; background-color: rgb(192, 192, 192);"><em>不支持</em></span><span style="word-wrap: normal; word-break: normal; line-height: 21px; color: rgb(255, 0, 0); font-size: 10.5pt; font-family: 'Courier new';">GenerationType.</span><span style="word-wrap: normal; word-break: normal; line-height: 21px; color: rgb(255, 0, 0); font-size: 10.5pt; font-family: 'Courier new'; background-color: rgb(192, 192, 192);"><em>SEQUENCE</em></span></p><p style="margin-top: 0pt; margin-bottom: 0pt; padding-top: 0px; padding-bottom: 0px; border: 0px; list-style-type: none; list-style-position: initial; word-wrap: normal; word-break: normal;"><span style="word-wrap: normal; word-break: normal; line-height: 21px; color: rgb(255, 0, 0); font-size: 10.5pt; font-family: 'Courier new'; background-color: rgb(192, 192, 192);"><em></em></span></p></td></tr><tr><td width="307" valign="top" style="margin: 0px; padding: 0pt 5.4pt; font-family: Verdana, 宋体, sans-serif; line-height: 18px; width: 230.4pt; border-left-width: 0.5pt; border-style: none solid solid; border-left-color: rgb(0, 0, 0); border-right-width: 0.5pt; border-right-color: rgb(0, 0, 0); border-bottom-width: 0.5pt; border-bottom-color: rgb(0, 0, 0);"><p style="margin-top: 0pt; margin-bottom: 0pt; padding-top: 0px; padding-bottom: 0px; border: 0px; list-style-type: none; list-style-position: initial; word-wrap: normal; word-break: normal;"><span style="word-wrap: normal; word-break: normal; line-height: 21px; font-size: 10.5pt; font-family: 宋体;">oracle</span></p></td><td width="307" valign="top" style="margin: 0px; padding: 0pt 5.4pt; font-family: Verdana, 宋体, sans-serif; line-height: 18px; width: 230.4pt; border-style: none solid solid none; border-right-width: 0.5pt; border-right-color: rgb(0, 0, 0); border-bottom-width: 0.5pt; border-bottom-color: rgb(0, 0, 0);"><p style="margin-top: 0pt; margin-bottom: 0pt; padding-top: 0px; padding-bottom: 0px; border: 0px; list-style-type: none; list-style-position: initial; word-wrap: normal; word-break: normal;"><span style="word-wrap: normal; word-break: normal; line-height: 21px; font-size: 10.5pt; font-family: 'Courier new';">strategy=</span><span style="word-wrap: normal; word-break: normal; line-height: 21px; font-size: 10.5pt; font-family: 'Courier new'; background-color: rgb(192, 192, 192);">GenerationType</span><span style="word-wrap: normal; word-break: normal; line-height: 21px; font-size: 10.5pt; font-family: 'Courier new';">.</span><span style="word-wrap: normal; word-break: normal; line-height: 21px; color: rgb(0, 0, 192); font-size: 10.5pt; font-family: 'Courier new';"><em>AUTO</em></span></p><p style="margin-top: 0pt; margin-bottom: 0pt; padding-top: 0px; padding-bottom: 0px; border: 0px; list-style-type: none; list-style-position: initial; word-wrap: normal; word-break: normal;"><span style="word-wrap: normal; word-break: normal; line-height: 21px; font-size: 10.5pt; font-family: 'Courier new';">GenerationType.</span><span style="word-wrap: normal; word-break: normal; line-height: 21px; color: rgb(0, 0, 192); font-size: 10.5pt; font-family: 'Courier new'; background-color: rgb(192, 192, 192);"><em>SEQUENCE</em></span></p><p style="margin-top: 0pt; margin-bottom: 0pt; padding-top: 0px; padding-bottom: 0px; border: 0px; list-style-type: none; list-style-position: initial; word-wrap: normal; word-break: normal;"><span style="word-wrap: normal; word-break: normal; line-height: 21px; font-size: 10.5pt; font-family: 'Courier new';">GenerationType.</span><span style="word-wrap: normal; word-break: normal; line-height: 21px; color: rgb(0, 0, 192); font-size: 10.5pt; font-family: 'Courier new'; background-color: rgb(192, 192, 192);"><em>TABLE</em></span></p><p style="margin-top: 0pt; margin-bottom: 0pt; padding-top: 0px; padding-bottom: 0px; border: 0px; list-style-type: none; list-style-position: initial; word-wrap: normal; word-break: normal;"><span style="word-wrap: normal; word-break: normal; line-height: 21px; color: rgb(255, 0, 0); font-size: 10.5pt; font-family: 宋体;"><em>不支持</em></span><span style="word-wrap: normal; word-break: normal; line-height: 21px; color: rgb(255, 0, 0); font-size: 10.5pt; font-family: 'Courier new';">GenerationType.</span><span style="word-wrap: normal; word-break: normal; line-height: 21px; color: rgb(255, 0, 0); font-size: 10.5pt; font-family: 'Courier new'; background-color: rgb(192, 192, 192);"><em>IDENTITY</em></span></p><p style="margin-top: 0pt; margin-bottom: 0pt; padding-top: 0px; padding-bottom: 0px; border: 0px; list-style-type: none; list-style-position: initial; word-wrap: normal; word-break: normal;"><span style="word-wrap: normal; word-break: normal; line-height: 21px; color: rgb(255, 0, 0); font-size: 10.5pt; font-family: 'Courier new'; background-color: rgb(192, 192, 192);"><em></em></span></p></td></tr><tr><td width="307" valign="top" style="margin: 0px; padding: 0pt 5.4pt; font-family: Verdana, 宋体, sans-serif; line-height: 18px; width: 230.4pt; border-left-width: 0.5pt; border-style: none solid solid; border-left-color: rgb(0, 0, 0); border-right-width: 0.5pt; border-right-color: rgb(0, 0, 0); border-bottom-width: 0.5pt; border-bottom-color: rgb(0, 0, 0);"><p style="margin-top: 0pt; margin-bottom: 0pt; padding-top: 0px; padding-bottom: 0px; border: 0px; list-style-type: none; list-style-position: initial; word-wrap: normal; word-break: normal;"><span style="word-wrap: normal; word-break: normal; line-height: 21px; font-size: 10.5pt; font-family: 宋体;">postgreSQL</span></p></td><td width="307" valign="top" style="margin: 0px; padding: 0pt 5.4pt; font-family: Verdana, 宋体, sans-serif; line-height: 18px; width: 230.4pt; border-style: none solid solid none; border-right-width: 0.5pt; border-right-color: rgb(0, 0, 0); border-bottom-width: 0.5pt; border-bottom-color: rgb(0, 0, 0);"><p style="margin-top: 0pt; margin-bottom: 0pt; padding-top: 0px; padding-bottom: 0px; border: 0px; list-style-type: none; list-style-position: initial; word-wrap: normal; word-break: normal;"><span style="word-wrap: normal; word-break: normal; line-height: 21px; font-size: 10.5pt; font-family: 'Courier new';">GenerationType.</span><span style="word-wrap: normal; word-break: normal; line-height: 21px; color: rgb(0, 0, 192); font-size: 10.5pt; font-family: 'Courier new'; background-color: rgb(192, 192, 192);"><em>TABLE</em></span></p><p style="margin-top: 0pt; margin-bottom: 0pt; padding-top: 0px; padding-bottom: 0px; border: 0px; list-style-type: none; list-style-position: initial; word-wrap: normal; word-break: normal;"><span style="word-wrap: normal; word-break: normal; line-height: 21px; font-size: 10.5pt; font-family: 'Courier new';">GenerationType.</span><span style="word-wrap: normal; word-break: normal; line-height: 21px; color: rgb(0, 0, 192); font-size: 10.5pt; font-family: 'Courier new'; background-color: rgb(192, 192, 192);"><em>AUTO</em></span></p><p style="margin-top: 0pt; margin-bottom: 0pt; padding-top: 0px; padding-bottom: 0px; border: 0px; list-style-type: none; list-style-position: initial; word-wrap: normal; word-break: normal;"><span style="word-wrap: normal; word-break: normal; line-height: 21px; font-size: 10.5pt; font-family: 'Courier new';">GenerationType.</span><span style="word-wrap: normal; word-break: normal; line-height: 21px; color: rgb(0, 0, 192); font-size: 10.5pt; font-family: 'Courier new'; background-color: rgb(192, 192, 192);"><em>IDENTITY</em></span></p><p style="margin-top: 0pt; margin-bottom: 0pt; padding-top: 0px; padding-bottom: 0px; border: 0px; list-style-type: none; list-style-position: initial; word-wrap: normal; word-break: normal;"><span style="word-wrap: normal; word-break: normal; line-height: 21px; font-size: 10.5pt; font-family: 'Courier new';">GenerationType.</span><span style="word-wrap: normal; word-break: normal; line-height: 21px; color: rgb(0, 0, 192); font-size: 10.5pt; font-family: 'Courier new'; background-color: rgb(192, 192, 192);"><em>SEQUENCE</em></span></p><p style="margin-top: 0pt; margin-bottom: 0pt; padding-top: 0px; padding-bottom: 0px; border: 0px; list-style-type: none; list-style-position: initial; word-wrap: normal; word-break: normal;"><span style="word-wrap: normal; word-break: normal; line-height: 21px; color: rgb(0, 0, 192); font-size: 10.5pt; font-family: 宋体; background-color: rgb(192, 192, 192);"><em>都支持</em></span></p><p style="margin-top: 0pt; margin-bottom: 0pt; padding-top: 0px; padding-bottom: 0px; border: 0px; list-style-type: none; list-style-position: initial; word-wrap: normal; word-break: normal;"><span style="word-wrap: normal; word-break: normal; line-height: 21px; color: rgb(0, 0, 192); font-size: 10.5pt; font-family: 宋体; background-color: rgb(192, 192, 192);"><em></em></span></p></td></tr><tr><td width="307" valign="top" style="margin: 0px; padding: 0pt 5.4pt; font-family: Verdana, 宋体, sans-serif; line-height: 18px; width: 230.4pt; border-left-width: 0.5pt; border-style: none solid solid; border-left-color: rgb(0, 0, 0); border-right-width: 0.5pt; border-right-color: rgb(0, 0, 0); border-bottom-width: 0.5pt; border-bottom-color: rgb(0, 0, 0);"><p style="margin-top: 0pt; margin-bottom: 0pt; padding-top: 0px; padding-bottom: 0px; border: 0px; list-style-type: none; list-style-position: initial; word-wrap: normal; word-break: normal;"><span style="word-wrap: normal; word-break: normal; line-height: 21px; font-size: 10.5pt; font-family: 宋体;">kingbase</span></p></td><td width="307" valign="top" style="margin: 0px; padding: 0pt 5.4pt; font-family: Verdana, 宋体, sans-serif; line-height: 18px; width: 230.4pt; border-style: none solid solid none; border-right-width: 0.5pt; border-right-color: rgb(0, 0, 0); border-bottom-width: 0.5pt; border-bottom-color: rgb(0, 0, 0);"><p style="margin-top: 0pt; margin-bottom: 0pt; padding-top: 0px; padding-bottom: 0px; border: 0px; list-style-type: none; list-style-position: initial; word-wrap: normal; word-break: normal;"><span style="word-wrap: normal; word-break: normal; line-height: 21px; font-size: 10.5pt; font-family: 'Courier new';">GenerationType.</span><span style="word-wrap: normal; word-break: normal; line-height: 21px; color: rgb(0, 0, 192); font-size: 10.5pt; font-family: 'Courier new'; background-color: rgb(192, 192, 192);"><em>TABLE</em></span></p><p style="margin-top: 0pt; margin-bottom: 0pt; padding-top: 0px; padding-bottom: 0px; border: 0px; list-style-type: none; list-style-position: initial; word-wrap: normal; word-break: normal;"><span style="word-wrap: normal; word-break: normal; line-height: 21px; font-size: 10.5pt; font-family: 'Courier new';">GenerationType.</span><span style="word-wrap: normal; word-break: normal; line-height: 21px; color: rgb(0, 0, 192); font-size: 10.5pt; font-family: 'Courier new'; background-color: rgb(192, 192, 192);"><em>SEQUENCE</em></span></p><p style="margin-top: 0pt; margin-bottom: 0pt; padding-top: 0px; padding-bottom: 0px; border: 0px; list-style-type: none; list-style-position: initial; word-wrap: normal; word-break: normal;"><span style="word-wrap: normal; word-break: normal; line-height: 21px; font-size: 10.5pt; font-family: 'Courier new';">GenerationType.</span><span style="word-wrap: normal; word-break: normal; line-height: 21px; color: rgb(0, 0, 192); font-size: 10.5pt; font-family: 'Courier new'; background-color: rgb(192, 192, 192);"><em>IDENTITY</em></span></p><p style="margin-top: 0pt; margin-bottom: 0pt; padding-top: 0px; padding-bottom: 0px; border: 0px; list-style-type: none; list-style-position: initial; word-wrap: normal; word-break: normal;"><span style="word-wrap: normal; word-break: normal; line-height: 21px; font-size: 10.5pt; font-family: 'Courier new';">GenerationType.</span><span style="word-wrap: normal; word-break: normal; line-height: 21px; color: rgb(0, 0, 192); font-size: 10.5pt; font-family: 'Courier new'; background-color: rgb(192, 192, 192);"><em>AUTO</em></span></p><p style="margin-top: 0pt; margin-bottom: 0pt; padding-top: 0px; padding-bottom: 0px; border: 0px; list-style-type: none; list-style-position: initial; word-wrap: normal; word-break: normal;"><span style="word-wrap: normal; word-break: normal; line-height: 21px; color: rgb(0, 0, 192); font-size: 10.5pt; font-family: 宋体; background-color: rgb(192, 192, 192);"><em>都支持</em></span></p></td></tr></tbody></table></div></div>



0 0
原创粉丝点击