你的位置:首页 > Java教程

[Java教程]hibernate+mysql 自动生成数据库问题


Hibernate Entity类

表名注解大写时,在windows下mysql自动生成的表都为小写(不区分大小写),在linux下mysql自动生成区分大小写。导致数据库问题。

原因(window下mysql不区分大小写,hibernate生成时全部生成小写,linux下生成时,按照注解大小写生成)

 1 package com.pera.report.designer.data; 2  3 import java.sql.Clob; 4  5 import javax.persistence.Basic; 6 import javax.persistence.Column; 7 import javax.persistence.Entity; 8 import javax.persistence.FetchType; 9 import javax.persistence.Lob;10 import javax.persistence.Table;11 12 import com.pera.maframework.core.common.entity.IdEntity;13 14 /**15  * 16  * 17  * @author zcj18  * 19  * @Time 2015-8-17 14:2120 */21 @Entity22 @Table(name = "qreport_)23 public class Reportextends IdEntity implements java.io.Serializable {24   /**25    * 26   */27   private static final long serialVersionUID = 8362245934322337549L;28   29   private Clob report30   31   private String reportName;32   33   private String reportMemo;34   35   @Lob36   @Basic(fetch = FetchType.EAGER)37   @Column(name = "reporttrue)38   public Clob getReport39     return report40   }41   public void setReport42     this.report report43   }44   45   @Column(name = "reportName")46   public String getReportName() {47     return reportName;48   }49   public void setReportName(String reportName) {50     this.reportName = reportName;51   }52   53   @Column(name = "reportMemo")54   public String getReportMemo() {55     return reportMemo;56   }57   public void setReportMemo(String reportMemo) {58     this.reportMemo = reportMemo;59   }60 }

View Code

解决方法:

http://blog.csdn.net/mlx212/article/details/23828151

或都改为小写,重新生成!