2017-01-19 5 views
1

私はSqlServer 2008 dbサーバーを使用しています。そして、 + jpa(hibernate)を使用してデータベースにアクセスしています。Hibernate @Columnアノテーションが機能しません

@Basic 
@Column(name = "AdminPickDate", nullable = true) 
public Timestamp getAdminPickDate() { 
    return adminPickDate; 
} 

そして休止SQL出力は、列名が注釈@Columeで名前を使用しないことを示しています

私はすでになど、エンティティのプロパティのアクセス方法に@Columnアノテーションを追加しています。

SQL出力:

Hibernate: select ddforumart0_.articleid as articlei1_95_0_, ddforumart0_.admin_pick_date as admin_pi2_95_0_, ddforumart0_.article_title as article_3_95_0_, ddforumart0_.article_type as article_4_95_0_, ddforumart0_.at_who as at_who5_95_0_, ddforumart0_.brief as brief6_95_0_, ddforumart0_.classifyid as classify7_95_0_, ddforumart0_.classify_title as classify8_95_0_, ddforumart0_.come_from as come_fro9_95_0_, ddforumart0_.comment_count as comment10_95_0_, ddforumart0_.comment_date as comment11_95_0_, ddforumart0_.comment_enable as comment12_95_0_, ddforumart0_.config as config13_95_0_, ddforumart0_.content as content14_95_0_, ddforumart0_.create_by as create_15_95_0_, ddforumart0_.create_date as create_16_95_0_, ddforumart0_.del_flag as del_fla17_95_0_, ddforumart0_.img_url as img_url18_95_0_, ddforumart0_.is_anonymous as is_anon19_95_0_, ddforumart0_.is_del_allow as is_del_20_95_0_, ddforumart0_.is_hot as is_hot21_95_0_, ddforumart0_.isqa as isqa22_95_0_, ddforumart0_.is_top as is_top23_95_0_, ddforumart0_.like_count as like_co24_95_0_, ddforumart0_.modify_by as modify_25_95_0_, ddforumart0_.modify_date as modify_26_95_0_, ddforumart0_.pick_date as pick_da27_95_0_, ddforumart0_.plateid as plateid28_95_0_, ddforumart0_.plate_title as plate_t29_95_0_, ddforumart0_.qatype as qatype30_95_0_, ddforumart0_.tags as tags31_95_0_, ddforumart0_.user_code as user_co32_95_0_, ddforumart0_.user_infoid as user_in33_95_0_, ddforumart0_.user_name as user_na34_95_0_, ddforumart0_.view_count as view_co35_95_0_ from dd_forum_article ddforumart0_ where ddforumart0_.articleid=? 

私のコードでは、いくつかの間違った使用法がありますか?

私のpom.xml:DdForumArticleRepository

package com.my.home.dao; 

import com.didi.home.model.DdForumArticle; 
import org.springframework.data.jpa.repository.JpaRepository; 
import org.springframework.stereotype.Component; 

/** 
* Created by [email protected] on 2017/1/13. 
*/ 
@Component 
public interface DdForumArticleRepository extends JpaRepository<DdForumArticle, Integer> { 
} 

エンティティコード:

package com.didi.home.model; 

import javax.persistence.Basic; 
import javax.persistence.Column; 
import javax.persistence.Entity; 
import javax.persistence.Id; 
import javax.persistence.Table; 
import java.sql.Timestamp; 

/** 
* Created by [email protected] on 2017/1/13. 
*/ 
// , schema = "dbo", catalog = "DB_DiDiWeb" 
@Entity 
@Table(name = "DD_Forum_Article") 
public class DdForumArticle { 
    private int articleId; 
    private Integer articleType; 
    private String articleTitle; 
    private String content; 
    private String brief; 
    private String atWho; 
    private String imgUrl; 
    private String tags; 
    private String config; 
    private Integer viewCount; 
    private Integer likeCount; 
    private Integer commentCount; 
    private Integer commentEnable; 
    private Timestamp commentDate; 
    private Integer isHot; 
    private Integer isTop; 
    private Integer isQa; 
    private String qaType; 
    private Timestamp pickDate; 
    private Timestamp adminPickDate; 
    private Integer plateId; 
    private String plateTitle; 
    private Integer classifyId; 
    private String classifyTitle; 
    private Integer userInfoId; 
    private String userName; 
    private String userCode; 
    private Integer delFlag; 
    private String createBy; 
    private Timestamp createDate; 
    private String modifyBy; 
    private Timestamp modifyDate; 
    private Integer isAnonymous; 
    private Integer isDelAllow; 
    private String comeFrom; 

    @Id 
    @Column(name = "ArticleID", nullable = false) 
    public int getArticleId() { 
     return articleId; 
    } 

    public void setArticleId(int articleId) { 
     this.articleId = articleId; 
    } 

    @Basic 
    @Column(name = "ArticleType", nullable = true) 
    public Integer getArticleType() { 
     return articleType; 
    } 

    public void setArticleType(Integer articleType) { 
     this.articleType = articleType; 
    } 

    @Basic 
    @Column(name = "ArticleTitle", nullable = true, length = 100) 
    public String getArticleTitle() { 
     return articleTitle; 
    } 

    public void setArticleTitle(String articleTitle) { 
     this.articleTitle = articleTitle; 
    } 

    @Basic 
    @Column(name = "Content", nullable = true, length = 2147483647) 
    public String getContent() { 
     return content; 
    } 

    public void setContent(String content) { 
     this.content = content; 
    } 

    @Basic 
    @Column(name = "Brief", nullable = true, length = 255) 
    public String getBrief() { 
     return brief; 
    } 

    public void setBrief(String brief) { 
     this.brief = brief; 
    } 

    @Basic 
    @Column(name = "AtWho", nullable = true, length = 2147483647) 
    public String getAtWho() { 
     return atWho; 
    } 

    public void setAtWho(String atWho) { 
     this.atWho = atWho; 
    } 

    @Basic 
    @Column(name = "ImgUrl", nullable = true, length = 2147483647) 
    public String getImgUrl() { 
     return imgUrl; 
    } 

    public void setImgUrl(String imgUrl) { 
     this.imgUrl = imgUrl; 
    } 

    @Basic 
    @Column(name = "Tags", nullable = true, length = 255) 
    public String getTags() { 
     return tags; 
    } 

    public void setTags(String tags) { 
     this.tags = tags; 
    } 

    @Basic 
    @Column(name = "Config", nullable = true, length = 2147483647) 
    public String getConfig() { 
     return config; 
    } 

    public void setConfig(String config) { 
     this.config = config; 
    } 

    @Basic 
    @Column(name = "ViewCount", nullable = true) 
    public Integer getViewCount() { 
     return viewCount; 
    } 

    public void setViewCount(Integer viewCount) { 
     this.viewCount = viewCount; 
    } 

    @Basic 
    @Column(name = "LikeCount", nullable = true) 
    public Integer getLikeCount() { 
     return likeCount; 
    } 

    public void setLikeCount(Integer likeCount) { 
     this.likeCount = likeCount; 
    } 

    @Basic 
    @Column(name = "CommentCount", nullable = true) 
    public Integer getCommentCount() { 
     return commentCount; 
    } 

    public void setCommentCount(Integer commentCount) { 
     this.commentCount = commentCount; 
    } 

    @Basic 
    @Column(name = "CommentEnable", nullable = true) 
    public Integer getCommentEnable() { 
     return commentEnable; 
    } 

    public void setCommentEnable(Integer commentEnable) { 
     this.commentEnable = commentEnable; 
    } 

    @Basic 
    @Column(name = "CommentDate", nullable = true) 
    public Timestamp getCommentDate() { 
     return commentDate; 
    } 

    public void setCommentDate(Timestamp commentDate) { 
     this.commentDate = commentDate; 
    } 

    @Basic 
    @Column(name = "IsHot", nullable = true) 
    public Integer getIsHot() { 
     return isHot; 
    } 

    public void setIsHot(Integer isHot) { 
     this.isHot = isHot; 
    } 

    @Basic 
    @Column(name = "IsTop", nullable = true) 
    public Integer getIsTop() { 
     return isTop; 
    } 

    public void setIsTop(Integer isTop) { 
     this.isTop = isTop; 
    } 

    @Basic 
    @Column(name = "IsQA", nullable = true) 
    public Integer getIsQa() { 
     return isQa; 
    } 

    public void setIsQa(Integer isQa) { 
     this.isQa = isQa; 
    } 

    @Basic 
    @Column(name = "QAType", nullable = true, length = 10) 
    public String getQaType() { 
     return qaType; 
    } 

    public void setQaType(String qaType) { 
     this.qaType = qaType; 
    } 

    @Basic 
    @Column(name = "PickDate", nullable = true) 
    public Timestamp getPickDate() { 
     return pickDate; 
    } 

    public void setPickDate(Timestamp pickDate) { 
     this.pickDate = pickDate; 
    } 

    @Basic 
    @Column(name = "AdminPickDate", nullable = true) 
    public Timestamp getAdminPickDate() { 
     return adminPickDate; 
    } 

    public void setAdminPickDate(Timestamp adminPickDate) { 
     this.adminPickDate = adminPickDate; 
    } 

    @Basic 
    @Column(name = "PlateID", nullable = true) 
    public Integer getPlateId() { 
     return plateId; 
    } 

    public void setPlateId(Integer plateId) { 
     this.plateId = plateId; 
    } 

    @Basic 
    @Column(name = "PlateTitle", nullable = true, length = 32) 
    public String getPlateTitle() { 
     return plateTitle; 
    } 

    public void setPlateTitle(String plateTitle) { 
     this.plateTitle = plateTitle; 
    } 

    @Basic 
    @Column(name = "ClassifyID", nullable = true) 
    public Integer getClassifyId() { 
     return classifyId; 
    } 

    public void setClassifyId(Integer classifyId) { 
     this.classifyId = classifyId; 
    } 

    @Basic 
    @Column(name = "ClassifyTitle", nullable = true, length = 32) 
    public String getClassifyTitle() { 
     return classifyTitle; 
    } 

    public void setClassifyTitle(String classifyTitle) { 
     this.classifyTitle = classifyTitle; 
    } 

    @Basic 
    @Column(name = "UserInfoID", nullable = true) 
    public Integer getUserInfoId() { 
     return userInfoId; 
    } 

    public void setUserInfoId(Integer userInfoId) { 
     this.userInfoId = userInfoId; 
    } 

    @Basic 
    @Column(name = "UserName", nullable = true, length = 32) 
    public String getUserName() { 
     return userName; 
    } 

    public void setUserName(String userName) { 
     this.userName = userName; 
    } 

    @Basic 
    @Column(name = "UserCode", nullable = true, length = 32) 
    public String getUserCode() { 
     return userCode; 
    } 

    public void setUserCode(String userCode) { 
     this.userCode = userCode; 
    } 

    @Basic 
    @Column(name = "DelFlag", nullable = true) 
    public Integer getDelFlag() { 
     return delFlag; 
    } 

    public void setDelFlag(Integer delFlag) { 
     this.delFlag = delFlag; 
    } 

    @Basic 
    @Column(name = "CreateBy", nullable = true, length = 32) 
    public String getCreateBy() { 
     return createBy; 
    } 

    public void setCreateBy(String createBy) { 
     this.createBy = createBy; 
    } 

    @Basic 
    @Column(name = "CreateDate", nullable = true) 
    public Timestamp getCreateDate() { 
     return createDate; 
    } 

    public void setCreateDate(Timestamp createDate) { 
     this.createDate = createDate; 
    } 

    @Basic 
    @Column(name = "ModifyBy", nullable = true, length = 32) 
    public String getModifyBy() { 
     return modifyBy; 
    } 

    public void setModifyBy(String modifyBy) { 
     this.modifyBy = modifyBy; 
    } 

    @Basic 
    @Column(name = "ModifyDate", nullable = true) 
    public Timestamp getModifyDate() { 
     return modifyDate; 
    } 

    public void setModifyDate(Timestamp modifyDate) { 
     this.modifyDate = modifyDate; 
    } 

    @Basic 
    @Column(name = "IsAnonymous", nullable = true) 
    public Integer getIsAnonymous() { 
     return isAnonymous; 
    } 

    public void setIsAnonymous(Integer isAnonymous) { 
     this.isAnonymous = isAnonymous; 
    } 

    @Basic 
    @Column(name = "IsDelAllow", nullable = true) 
    public Integer getIsDelAllow() { 
     return isDelAllow; 
    } 

    public void setIsDelAllow(Integer isDelAllow) { 
     this.isDelAllow = isDelAllow; 
    } 

    @Basic 
    @Column(name = "ComeFrom", nullable = true, length = 32) 
    public String getComeFrom() { 
     return comeFrom; 
    } 

    public void setComeFrom(String comeFrom) { 
     this.comeFrom = comeFrom; 
    } 

    @Override 
    public boolean equals(Object o) { 
     if (this == o) return true; 
     if (o == null || getClass() != o.getClass()) return false; 

     DdForumArticle that = (DdForumArticle) o; 

     if (articleId != that.articleId) return false; 
     if (articleType != null ? !articleType.equals(that.articleType) : that.articleType != null) return false; 
     if (articleTitle != null ? !articleTitle.equals(that.articleTitle) : that.articleTitle != null) return false; 
     if (content != null ? !content.equals(that.content) : that.content != null) return false; 
     if (brief != null ? !brief.equals(that.brief) : that.brief != null) return false; 
     if (atWho != null ? !atWho.equals(that.atWho) : that.atWho != null) return false; 
     if (imgUrl != null ? !imgUrl.equals(that.imgUrl) : that.imgUrl != null) return false; 
     if (tags != null ? !tags.equals(that.tags) : that.tags != null) return false; 
     if (config != null ? !config.equals(that.config) : that.config != null) return false; 
     if (viewCount != null ? !viewCount.equals(that.viewCount) : that.viewCount != null) return false; 
     if (likeCount != null ? !likeCount.equals(that.likeCount) : that.likeCount != null) return false; 
     if (commentCount != null ? !commentCount.equals(that.commentCount) : that.commentCount != null) return false; 
     if (commentEnable != null ? !commentEnable.equals(that.commentEnable) : that.commentEnable != null) 
      return false; 
     if (commentDate != null ? !commentDate.equals(that.commentDate) : that.commentDate != null) return false; 
     if (isHot != null ? !isHot.equals(that.isHot) : that.isHot != null) return false; 
     if (isTop != null ? !isTop.equals(that.isTop) : that.isTop != null) return false; 
     if (isQa != null ? !isQa.equals(that.isQa) : that.isQa != null) return false; 
     if (qaType != null ? !qaType.equals(that.qaType) : that.qaType != null) return false; 
     if (pickDate != null ? !pickDate.equals(that.pickDate) : that.pickDate != null) return false; 
     if (adminPickDate != null ? !adminPickDate.equals(that.adminPickDate) : that.adminPickDate != null) 
      return false; 
     if (plateId != null ? !plateId.equals(that.plateId) : that.plateId != null) return false; 
     if (plateTitle != null ? !plateTitle.equals(that.plateTitle) : that.plateTitle != null) return false; 
     if (classifyId != null ? !classifyId.equals(that.classifyId) : that.classifyId != null) return false; 
     if (classifyTitle != null ? !classifyTitle.equals(that.classifyTitle) : that.classifyTitle != null) 
      return false; 
     if (userInfoId != null ? !userInfoId.equals(that.userInfoId) : that.userInfoId != null) return false; 
     if (userName != null ? !userName.equals(that.userName) : that.userName != null) return false; 
     if (userCode != null ? !userCode.equals(that.userCode) : that.userCode != null) return false; 
     if (delFlag != null ? !delFlag.equals(that.delFlag) : that.delFlag != null) return false; 
     if (createBy != null ? !createBy.equals(that.createBy) : that.createBy != null) return false; 
     if (createDate != null ? !createDate.equals(that.createDate) : that.createDate != null) return false; 
     if (modifyBy != null ? !modifyBy.equals(that.modifyBy) : that.modifyBy != null) return false; 
     if (modifyDate != null ? !modifyDate.equals(that.modifyDate) : that.modifyDate != null) return false; 
     if (isAnonymous != null ? !isAnonymous.equals(that.isAnonymous) : that.isAnonymous != null) return false; 
     if (isDelAllow != null ? !isDelAllow.equals(that.isDelAllow) : that.isDelAllow != null) return false; 
     if (comeFrom != null ? !comeFrom.equals(that.comeFrom) : that.comeFrom != null) return false; 

     return true; 
    } 

    @Override 
    public int hashCode() { 
     int result = articleId; 
     result = 31 * result + (articleType != null ? articleType.hashCode() : 0); 
     result = 31 * result + (articleTitle != null ? articleTitle.hashCode() : 0); 
     result = 31 * result + (content != null ? content.hashCode() : 0); 
     result = 31 * result + (brief != null ? brief.hashCode() : 0); 
     result = 31 * result + (atWho != null ? atWho.hashCode() : 0); 
     result = 31 * result + (imgUrl != null ? imgUrl.hashCode() : 0); 
     result = 31 * result + (tags != null ? tags.hashCode() : 0); 
     result = 31 * result + (config != null ? config.hashCode() : 0); 
     result = 31 * result + (viewCount != null ? viewCount.hashCode() : 0); 
     result = 31 * result + (likeCount != null ? likeCount.hashCode() : 0); 
     result = 31 * result + (commentCount != null ? commentCount.hashCode() : 0); 
     result = 31 * result + (commentEnable != null ? commentEnable.hashCode() : 0); 
     result = 31 * result + (commentDate != null ? commentDate.hashCode() : 0); 
     result = 31 * result + (isHot != null ? isHot.hashCode() : 0); 
     result = 31 * result + (isTop != null ? isTop.hashCode() : 0); 
     result = 31 * result + (isQa != null ? isQa.hashCode() : 0); 
     result = 31 * result + (qaType != null ? qaType.hashCode() : 0); 
     result = 31 * result + (pickDate != null ? pickDate.hashCode() : 0); 
     result = 31 * result + (adminPickDate != null ? adminPickDate.hashCode() : 0); 
     result = 31 * result + (plateId != null ? plateId.hashCode() : 0); 
     result = 31 * result + (plateTitle != null ? plateTitle.hashCode() : 0); 
     result = 31 * result + (classifyId != null ? classifyId.hashCode() : 0); 
     result = 31 * result + (classifyTitle != null ? classifyTitle.hashCode() : 0); 
     result = 31 * result + (userInfoId != null ? userInfoId.hashCode() : 0); 
     result = 31 * result + (userName != null ? userName.hashCode() : 0); 
     result = 31 * result + (userCode != null ? userCode.hashCode() : 0); 
     result = 31 * result + (delFlag != null ? delFlag.hashCode() : 0); 
     result = 31 * result + (createBy != null ? createBy.hashCode() : 0); 
     result = 31 * result + (createDate != null ? createDate.hashCode() : 0); 
     result = 31 * result + (modifyBy != null ? modifyBy.hashCode() : 0); 
     result = 31 * result + (modifyDate != null ? modifyDate.hashCode() : 0); 
     result = 31 * result + (isAnonymous != null ? isAnonymous.hashCode() : 0); 
     result = 31 * result + (isDelAllow != null ? isDelAllow.hashCode() : 0); 
     result = 31 * result + (comeFrom != null ? comeFrom.hashCode() : 0); 
     return result; 
    } 
} 
ここ

<?xml version="1.0" encoding="UTF-8"?> 
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
     xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 
    <modelVersion>4.0.0</modelVersion> 

    <groupId>com.didi.home.dao</groupId> 
    <artifactId>didi-home-dao</artifactId> 
    <version>0.0.1-SNAPSHOT</version> 
    <packaging>jar</packaging> 

    <name>didi-home-dao</name> 
    <description>didi home data producer</description> 

    <parent> 
     <groupId>org.springframework.boot</groupId> 
     <artifactId>spring-boot-starter-parent</artifactId> 
     <version>1.4.1.RELEASE</version> 
     <relativePath/> <!-- lookup parent from repository --> 
    </parent> 

    <properties> 
     <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> 
     <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> 
     <java.version>1.8</java.version> 
    </properties> 

    <dependencies> 
     <dependency> 
      <groupId>com.didi.home.model</groupId> 
      <artifactId>didi-home-model</artifactId> 
      <version>1.0.0-SNAPSHOT</version> 
     </dependency> 

     <dependency> 
      <groupId>com.microsoft.sqlserver</groupId> 
      <artifactId>sqljdbc4</artifactId> 
      <version>4.0</version> 
     </dependency> 

     <dependency> 
      <groupId>org.springframework.boot</groupId> 
      <artifactId>spring-boot-starter-data-jpa</artifactId> 
     </dependency> 
     <dependency> 
      <groupId>org.springframework.boot</groupId> 
      <artifactId>spring-boot-starter-jdbc</artifactId> 
     </dependency> 
     <dependency> 
      <groupId>org.springframework.boot</groupId> 
      <artifactId>spring-boot-starter-test</artifactId> 
      <scope>test</scope> 
     </dependency> 

    </dependencies> 

    <build> 
     <plugins> 
      <plugin> 
       <groupId>org.springframework.boot</groupId> 
       <artifactId>spring-boot-maven-plugin</artifactId> 
      </plugin> 
     </plugins> 
    </build> 


</project> 

application.yml

spring: 
    datasource: 
    url: jdbc:sqlserver://1.2.3.4:1433;databaseName=DB_DiDiWeb 
    username: u 
    password: mypwd 
    jpa: 
    show-sql: true 
    hibernate: 
     naming: 
#  strategy: org.hibernate.cfg.EJB3NamingStrategy 
#  strategy: org.hibernate.cfg.DefaultComponentSafeNamingStrategy 
#  strategy: org.hibernate.cfg.DefaultNamingStrategy 
#  strategy: org.hibernate.cfg.ImprovedNamingStrategy 
#  strategy: org.springframework.boot.orm.jpa.hibernate.SpringNamingStrategy 

は、デモ・リポジトリです

テストコード:

package com.didi.home.dao; 

import com.didi.home.model.DdForumArticle; 
import org.junit.Test; 
import org.junit.runner.RunWith; 
import org.springframework.beans.factory.annotation.Autowired; 
import org.springframework.boot.test.context.SpringBootTest; 
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; 

/** 
* Created by [email protected] on 2017/1/13. 
*/ 
@RunWith(SpringJUnit4ClassRunner.class) 
@SpringBootTest(classes = Application.class) 
public class DdForumArticleRepositoryTest { 

    @Autowired 
    DdForumArticleRepository repository; 

    @Test 
    public void test() { 
     DdForumArticle one = repository.findOne(52); 
     System.out.println(one); 
    } 
} 

と例外スタックトレース:

Caused by: com.microsoft.sqlserver.jdbc.SQLServerException: Invalid Column name 'admin_pick_date' 
    at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDatabaseError(SQLServerException.java:216) 
    at com.microsoft.sqlserver.jdbc.SQLServerStatement.getNextResult(SQLServerStatement.java:1515) 
    at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.doExecutePreparedStatement(SQLServerPreparedStatement.java:404) 
    at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement$PrepStmtExecCmd.doExecute(SQLServerPreparedStatement.java:350) 
    at com.microsoft.sqlserver.jdbc.TDSCommand.execute(IOBuffer.java:5696) 
    at com.microsoft.sqlserver.jdbc.SQLServerConnection.executeCommand(SQLServerConnection.java:1715) 
    at com.microsoft.sqlserver.jdbc.SQLServerStatement.executeCommand(SQLServerStatement.java:180) 
    at com.microsoft.sqlserver.jdbc.SQLServerStatement.executeStatement(SQLServerStatement.java:155) 
    at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.executeQuery(SQLServerPreparedStatement.java:285) 
    at org.hibernate.engine.jdbc.internal.ResultSetReturnImpl.extract(ResultSetReturnImpl.java:70) 
    ... 81 more 

EDIT:テーブルスキーマを追加

CREATE TABLE [dbo].[DD_Forum_Article] (
    [ArticleID] int IDENTITY(1,1) NOT NULL, 
    [ArticleType] int NULL, 
    [ArticleTitle] nvarchar(100) COLLATE Chinese_PRC_CI_AS NULL, 
    [Content] nvarchar(max) COLLATE Chinese_PRC_CI_AS NULL, 
    [Brief] nvarchar(255) COLLATE Chinese_PRC_CI_AS NULL, 
    [AtWho] nvarchar(max) COLLATE Chinese_PRC_CI_AS NULL, 
    [ImgUrl] nvarchar(max) COLLATE Chinese_PRC_CI_AS NULL, 
    [Tags] nvarchar(255) COLLATE Chinese_PRC_CI_AS NULL, 
    [Config] nvarchar(max) COLLATE Chinese_PRC_CI_AS NULL, 
    [ViewCount] int NULL, 
    [LikeCount] int NULL, 
    [CommentCount] int NULL, 
    [CommentEnable] int NULL, 
    [CommentDate] datetime NULL, 
    [IsHot] int NULL, 
    [IsTop] int NULL, 
    [IsQA] int NULL, 
    [QAType] varchar(10) COLLATE Chinese_PRC_CI_AS NULL, 
    [PickDate] datetime NULL, 
    [AdminPickDate] datetime NULL, 
    [PlateID] int NULL, 
    [PlateTitle] nvarchar(32) COLLATE Chinese_PRC_CI_AS NULL, 
    [ClassifyID] int NULL, 
    [ClassifyTitle] nvarchar(32) COLLATE Chinese_PRC_CI_AS NULL, 
    [UserInfoID] int NULL, 
    [UserName] nvarchar(32) COLLATE Chinese_PRC_CI_AS NULL, 
    [UserCode] nvarchar(32) COLLATE Chinese_PRC_CI_AS NULL, 
    [DelFlag] int NULL, 
    [CreateBy] nvarchar(32) COLLATE Chinese_PRC_CI_AS NULL, 
    [CreateDate] datetime NULL, 
    [ModifyBy] nvarchar(32) COLLATE Chinese_PRC_CI_AS NULL, 
    [ModifyDate] datetime NULL, 
    [IsAnonymous] int NULL DEFAULT ((0)), 
    [IsDelAllow] int NULL, 
    [ComeFrom] nvarchar(32) COLLATE Chinese_PRC_CI_AS NULL 
) 
ON [PRIMARY] 
TEXTIMAGE_ON [PRIMARY] 
+0

JPA仕様は春に続いされていないためです。 '@Column'アノテーション名を無視するように、Hibernateの命名スタイルを明示的に設定しています。 Springのようなソフトウェアが移植性を捨てるとJPA仕様がテーブル/カラム命名の標準を定義する手間になったのはなぜですか?列は 'AdminPickDate'である必要がありますが、内部的に 'Admin_Pick_Date'を使用しています –

+0

Neilに感謝しますが、この問題を解決する方法はありますか? – BeeNoisy

+0

Springを使用しないでください。 JPA仕様と一貫性のあるHibernate命名戦略を選択しますか?私はDataNucleusを使用しているので、仕様の一貫した命名を得ることができます。したがって、Hibernateの仕様についてお手伝いできません。 –

答えて

0

チェックadmin_pick_date文字列フィールド名とそのデータ型(上下ケース)を対応する値で除算します。

グッドラック

+0

私はすでにテーブルスキーマをチェックしています、フィールド名は正しいです。 BTWテーブルスキーマが質問本体に追加されました。 – BeeNoisy

+0

コードのフィールド名はどうですか?エラーはあなたがこのadmin_pick_dateのような下線を持っていたと言う。 –

+1

エンティティコードを参照してください。私はすでに 'getter'メソッドにColumn(name = 'AdminPickDate')を追加しています。 – BeeNoisy

0

MSSQL Serverは

編集設定に基づいて、大文字と小文字を区別することができます:それは私のミスでした。あなたは以前から何かを変えましたか?

application.propertiesファイルで次のように設定しましたか?

spring.jpa.hibernate.naming_strategy=org.hibernate.cfg.EJB3NamingStrategy 
+0

@Columnアノテーションは、hibernate-metadata-generatorによって生成されました。テーブルスキーマにはAdminPickDateというファイルが作成されていました(これはcreate tableステートメントに表示されています)。 SQLの出力に気づいた場合、SQLはadmin_pick_dateを使用してデータを選択しますが、列の注釈を書き込む 'AdminPickDate'では使用できません。 – BeeNoisy

+0

お返事ありがとうございます、私はすべての命名戦略を試しています:(org.hibernate.cfg.EJB3NamingStrategy | org.hibernate.cfg.DefaultComponentSafeNamingStrategy | org.hibernate.cfg.DefaultNamingStrategy | org.hibernate.cfg.ImprovedNamingStrategy | org.springframework .boot.orm.jpa.hibernate.SpringNamingStrategy)しかし、誰もそれを置いた – BeeNoisy

+0

はありませんか?あなたはそのファイルをここに置くことができます –

0

コンフィグにこれを追加することで、私の質問は解決されました:

spring.jpa.hibernate.naming.implicit-strategy=org.hibernate.boot.model.naming.ImplicitNamingStrategyLegacyJpaImpl 
spring.jpa.hibernate.naming.physical-strategy=org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl 
関連する問題