Eclipselink Mysql表名大写

时间:2015-05-18 20:47:58

标签: java mysql jpa eclipselink

我有两个实体类Member和EvaluationType。它们是关系表。

成员:

    /*******************************************************************
    **  ACTION SCRIPT TO POST A NEW CATEGORY INTO THE DOC_LIST TABLE  **
    *******************************************************************/


    if(isset($_POST["action"])){
    if(isset($_POST["submit"])){
    include_once'../../config.php';

    try {

    $dbh = new PDO("mysql:host=$hostname;dbname=dashboardr",$username,$password);
    $dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
    $sql = "INSERT INTO doc_list (doc_title, doc_content, doc_created, user_id) 
            VALUES ('".$_POST["doc_title"]."','".$_POST["doc_content"]."',NOW(), '".$_SESSION['user']."')";

    $SQL = "INSERT INTO `cat_doc_link_table`(`link_cat_id`, `link_doc_id`) VALUES";
    $values = "";
    $params = [];
    $docId = $dbh->lastInsertId();

    foreach($_POST["cat_no"] as $cat)
    {
        $values.= "(?, ?), ";
        $params[] = $cat["cat_id"];
        $params[] = $docId;
    }
    $values = substr($values, 0, -2);
    $SQL.= $values;
    $query = $dbh->prepare($SQL);
    $query->execute($params);       

    if ($dbh->query($sql)) {

        header ('Location: ../docList.php?success=1');
    }else{
    }

    $dbh = null;
        }catch(PDOException $e)
    {
        echo $e->getMessage();
    }

    }

    }


    ?>

评估类型:

@ManyToOne
@JoinColumn(name = "evaluationId")
private EvaluationType evaluationType;

当我运行应用程序时,我收到以下错误:

错误代码:1215 调用:ALTER TABLE MEMBER ADD CONSTRAINT FK_MEMBER_evaluationId FOREIGN KEY(evaluationId)REFERENCESEVALUATİONTYPE(evaluationId) 查询:DataModifyQuery(sql =“ALTER TABLE MEMBER ADD CONSTRAINT FK_MEMBER_evaluationId FOREIGN KEY(evaluationId)REFERENCESEVALUATİONTYPE(evaluationId)”)

错误是“EVALUATİONTYPE”表名。因为mysql中没有大写表名。我怎样才能解决这个问题?

1 个答案:

答案 0 :(得分:1)

另一种选择是在数据库本身中设置区分大小写。检查https://dev.mysql.com/doc/refman/5.0/en/identifier-case-sensitivity.html lower_case_table_names = 1将以小写形式存储所有表名,并使名称比较不区分大小写。 但@Table注释也应该起作用。所以这取决于你。