当前位置: 首页 > news >正文

怎么样在百度搜到自己的网站高端房产网站建设

怎么样在百度搜到自己的网站,高端房产网站建设,百度官网首页官网,西安软件制作现在的情况是#xff0c;在MySQL中有db1和db2两个数据库。项目使用Hibernate#xff0c;可同时访问db1和db2#xff0c;默认数据库为db1。表table2在db2中。且table2的主键名为ids#xff0c;是自增长字段#xff08;Auto Increment#xff09;。 table2和ids的定义为在MySQL中有db1和db2两个数据库。项目使用Hibernate可同时访问db1和db2默认数据库为db1。表table2在db2中。且table2的主键名为ids是自增长字段Auto Increment。 table2和ids的定义为 Entity Table(name table2, schema db2) Cache(usage CacheConcurrencyStrategy.READ_WRITE) public class Table2 implements java.io.Serializable {private static final long serialVersionUID 48L;IdColumn(name ids)GeneratedValue(generator idGenerator, strategy GenerationType.IDENTITY)GenericGenerator(name idGenerator, strategy increment)private Integer ids; 当向table2中保存数据时会报错。原因是生成ids时系统会查询table2中ids的最大值。语句是 select max(ids) from table2 由于默认数据库是db1因此查询的是db1.table2表。但table2表实际上在db2中所以系统找不到该表从而报错。 这就需要在GenericGenerator中指定max查询语句的schema。通过检查错误信息发现对应代码在org.hibernate.id.IncrementGenerator.configure()方法中如下 public void configure(Type type, Properties params, Dialect dialect) throws MappingException {returnClass type.getReturnedClass();ObjectNameNormalizer normalizer ( ObjectNameNormalizer ) params.get( PersistentIdentifierGenerator.IDENTIFIER_NORMALIZER );String column params.getProperty( column );if ( column null ) {column params.getProperty( PersistentIdentifierGenerator.PK );}column dialect.quote( normalizer.normalizeIdentifierQuoting( column ) );String tableList params.getProperty( tables );if ( tableList null ) {tableList params.getProperty( PersistentIdentifierGenerator.TABLES );}String[] tables StringHelper.split( , , tableList );final String schema dialect.quote(normalizer.normalizeIdentifierQuoting(params.getProperty( PersistentIdentifierGenerator.SCHEMA )));final String catalog dialect.quote(normalizer.normalizeIdentifierQuoting(params.getProperty( PersistentIdentifierGenerator.CATALOG )));StringBuilder buf new StringBuilder();for ( int i0; i tables.length; i ) {final String tableName dialect.quote( normalizer.normalizeIdentifierQuoting( tables[i] ) );if ( tables.length 1 ) {buf.append( select max( ).append( column ).append( ) as mx from );}buf.append( Table.qualify( catalog, schema, tableName ) );if ( i tables.length-1 ) {buf.append( union );}}if ( tables.length 1 ) {buf.insert( 0, ( ).append( ) ids_ );column ids_.mx;}sql select max( column ) from buf.toString();} 在初始化Table2实体类时该方法就会执行。作用是生成对应数据库的select max语句。 在IncrementGenerator的注释中有一段话 Mapping parameters supported, but not usually needed: tables, column. (The tables parameter specified a comma-separated list of table names.) 说明在GenericGenerator中可以设置参数。在IncrementGenerator.configure()方法中可以将这些参数读出来。读取参数的方法为params.getProperty(参数名)。例如 params.getProperty( column ) 就是读取column参数的值。对应读取schema的语句为 final String schema dialect.quote(normalizer.normalizeIdentifierQuoting(params.getProperty( PersistentIdentifierGenerator.SCHEMA )) ); schema的参数名就是PersistentIdentifierGenerator.SCHEMA也就是schema。其他预置保留参数的值大都在org.hibernate.id.PersistentIdentifierGenerator中定义。如 public interface PersistentIdentifierGenerator extends IdentifierGenerator {/*** The configuration parameter holding the schema name*/public static final String SCHEMA schema;/*** The configuration parameter holding the table name for the* generated id*/public static final String TABLE target_table;/*** The configuration parameter holding the table names for all* tables for which the id must be unique*/public static final String TABLES identity_tables;/*** The configuration parameter holding the primary key column* name of the generated id*/public static final String PK target_column;/*** The configuration parameter holding the catalog name*/public static final String CATALOG catalog;/*** The key under whcih to find the {link org.hibernate.cfg.ObjectNameNormalizer} in the config param map.*/public static final String IDENTIFIER_NORMALIZER identifier_normalizer; 在GenericGenerator中设置parameter的方法为 Id Column(name ids) GeneratedValue(generator idGenerator, strategy GenerationType.IDENTITY) GenericGenerator(name idGenerator, strategy increment, parameters Parameter(name PersistentIdentifierGenerator.SCHEMA, value db2)) private Integer ids; 这样就能在table2前加上正确的schema名称db2生成正确的查询语句 select max(ids) from db2.table2 如果有多个参数可以写为 GenericGenerator(name idGenerator, strategy increment, parameters {             Parameter(name PersistentIdentifierGenerator.SCHEMA, value db2),             Parameter(namePersistentIdentifierGenerator.CATALOG, value db2) })
http://www.w-s-a.com/news/328503/

相关文章:

  • 邯郸做移动网站多少钱ui设计好就业吗
  • 共享虚拟主机普惠版做网站产品推广包括哪些内容
  • 广州市网站建站免费咨询医生有问必答
  • app网站建设制作哪个网站可以做魔方图片
  • 教育培训网站建设方案模板下载网站文风
  • 电龙网站建设wordpress文章两端对齐
  • 做外单网站亚马逊免费的网站加速器
  • 英文网站推广工作一个虚拟主机可以做几个网站吗
  • 微网站 合同重庆电力建设设计公司网站
  • 网站怎么设置支付网站源码下载后怎么布置
  • 广州市公需课在哪个网站可以做手机商城软件下载
  • app网站建设需要什么长治网站建设公司
  • 网站模板平台广告宣传网站
  • cc域名的网站做网站放太多视频
  • 让公司做网站要注意什么建设工程公司企业文化
  • 佛山搭建建网站哪家好微信如何建立自己的公众号
  • 联想公司网站建设现状广州建网站兴田德润团队
  • 网站开发的技术有网页设计实训报告工作内容和步骤
  • 视频做网站长沙网站制作平台
  • js网站建设北京seo公司优化网络可见性
  • 付款网站源码建网站卖东西
  • 用php做的录入成绩的网站wordpress等级插件
  • 网站运营优化方案广西桂林公司
  • 快递网站策划怎么做ppt长春建设信息网站
  • 做服装搭配图的网站有哪些经营一个网站要怎么做
  • 呼市品牌网站建设那家好增城住房和建设局网站
  • 网站首页布局设计代码太仓网站开发建设服务
  • 学校网站建设与管理porto wordpress模板
  • 余姚做网站公司网站建设有哪些基本流程
  • 门户网站建设的报价百度医生在线问诊