2010-07-02 61 views
0

我是hibernate的新手。 在我的表中映射 時,我面臨的問題是沒有主鍵。但有兩個NOT NULL值是有 我怎麼可以在休眠代表他們提前 感謝如何在休眠中映射

我的表結構是這樣的

Field     Type   Collation   Null Key  Default Extra   Privileges      Comment 
---------------------- ----------- ----------------- ------ ------ ------- -------------- ------------------------------- ------- 
ApplicationId   bigint(20) (NULL)    NO  PRI  (NULL) auto_increment select,insert,update,references   
ApplicationName   varchar(32) latin1_swedish_ci YES    (NULL)     select,insert,update,references   
IsTimeSubsciptionValid tinyint(4) (NULL)    YES    0      select,insert,update,references   
IsUserCountValid  tinyint(4) (NULL)    YES    0      select,insert,update,references   
MaxUserCount   int(11)  (NULL)    YES    0      select,insert,update,references   
IsMaxAccessCountValid tinyint(4) (NULL)    YES    0      select,insert,update,references   
MaxAccessCount   bigint(20) (NULL)    YES    0      select,insert,update,references   
IsParentingAvailable tinyint(4) (NULL)    YES    0      select,insert,update,references   
TimePeriodAllowed  bigint(20) (NULL)    YES    0      select,insert,update,references   


Table Query. 

Table    Create Table           
---------------- ------------------------------------------------------- 
ApplicationTable CREATE TABLE `ApplicationTable` (      
        `ApplicationId` bigint(20) NOT NULL auto_increment, 
        `ApplicationName` varchar(32) default NULL,   
        `IsTimeSubsciptionValid` tinyint(4) default '0',  
        `IsUserCountValid` tinyint(4) default '0',   
        `MaxUserCount` int(11) default '0',     
        `IsMaxAccessCountValid` tinyint(4) default '0',  
        `MaxAccessCount` bigint(20) default '0',    
        `IsParentingAvailable` tinyint(4) default '0',  
        `TimePeriodAllowed` bigint(20) default '0',   
        PRIMARY KEY (`ApplicationId`)      
       ) ENGINE=MyISAM DEFAULT CHARSET=latin1     

回答

0

您可能已經發現了Hibernate的需要主鍵,即使桌子上沒有人。任何獨特的密鑰都可以(我相信也有一種使用ROWID的方法)。

它看起來像你想是這樣的:

<id name="ApplicationId" column="APPLICATIONID"> 
    </id> 

,但你說有2個要映射不是空值?至於問題是什麼,我有點不清楚。

+0

顯然你並不在乎這麼多?希望有人會回答我的一些問題。 – orbfish 2011-03-06 19:42:47