2011-10-10 49 views
0

以下非常重要的是我的.hbm.xml休眠錯誤 - 小問題,但

<?xml version="1.0"?> 
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" 
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd"> 
<hibernate-mapping> 
    <class name="com.mmm.data.UserRating" table="userratings" catalog="mmm"> 
     <composite-id name="id" class="mmm.UserRatingId"> 
      <key-property name="userId" type="int"> 
       <column name="userId" /> 
      </key-property> 
      <key-property name="recipeId" type="int"> 
       <column name="recipeId" /> 
      </key-property> 
     </composite-id> 
     <many-to-one name="recipe" class="com.mmm.data.Recipe" update="false" insert="false" fetch="select"> 
      <column name="recipeId" not-null="true" /> 
     </many-to-one> 
     <many-to-one name="user" class="com.mmm.data.User" update="false" insert="false" fetch="select"> 
      <column name="userId" not-null="true" /> 
     </many-to-one> 
     <property name="rating" type="int"> 
      <column name="rating" not-null="true" /> 
     </property> 
    </class> 
</hibernate-mapping> 

這裏是Java:

public class UserRating implements java.io.Serializable 
{ 
    private UserRatingId id; 
    private Recipe   recipe; 
    private User   user; 
    private int    rating; 


    /** 
    * 
    */ 
    public UserRating() 
    { 
    } 

    /** 
    * 
    * @param id 
    * @param recipes 
    * @param users 
    * @param rating 
    */ 
    public UserRating( UserRatingId id, 
         Recipe   recipes, 
         User   users, 
         int    rating) 
    { 
     this.id  = id; 
     this.recipe = recipes; 
     this.user = users; 
     this.rating = rating; 
    } 

    public UserRating( UserRatingId id) 
    { 
     this.id  = id; 
    } 

    /** 
    * 
    * @return 
    */ 
    public UserRatingId getId() 
    { 
     return this.id; 
    } 

    /** 
    * 
    * @param id 
    */ 
    public void setId(UserRatingId id) 
    { 
     this.id = id; 
    } 

    /** 
    * 
    * @return 
    */ 
    public Recipe getRecipe() 
    { 
     return this.recipe; 
    } 

    /** 
    * 
    * @param recipe 
    */ 
    public void setRecipe(Recipe recipe) 
    { 
     this.recipe = recipe; 
    } 

    /** 
    * 
    * @return 
    */ 
    public User getUser() 
    { 
     return this.user; 
    } 

    /** 
    * 
    * @param user 
    */ 
    public void setUser(User user) 
    { 
     this.user = user; 
    } 

    /** 
    * 
    * @return 
    */ 
    public int getRating() 
    { 
     return this.rating; 
    } 

    /** 
    * 
    * @param rating 
    */ 
    public void setRating(int rating) 
    { 
     this.rating = rating; 
    } 
} 

public class UserRatingId implements java.io.Serializable 
{ 
    private int userId; 
    private int recipeId; 

    /** 
    * 
    */ 
    public UserRatingId() 
    { 
    } 

    /** 
    * 
    * @param userId 
    * @param recipeId 
    */ 
    public UserRatingId( int userId, 
          int recipeId) 
    { 
     this.userId = userId; 
     this.recipeId = recipeId; 
    } 

    /** 
    * 
    * @return 
    */ 
    public int getUserId() 
    { 
     return this.userId; 
    } 

    /** 
    * 
    * @param userId 
    */ 
    public void setUserId(int userId) 
    { 
     this.userId = userId; 
    } 

    /** 
    * 
    * @return 
    */ 
    public int getRecipeId() 
    { 
     return this.recipeId; 
    } 

    /** 
    * 
    * @param recipeId 
    */ 
    public void setRecipeId(int recipeId) 
    { 
     this.recipeId = recipeId; 
    } 

    /** 
    * 
    */ 
    public boolean equals(Object other) 
    { 
     if ((this == other)) 
      return true; 

     if ((other == null)) 
      return false; 

     if (!(other instanceof UserRatingId)) 
      return false; 

     UserRatingId castOther = (UserRatingId) other; 

     return (this.getUserId() == castOther.getUserId()) 
       && (this.getRecipeId() == castOther.getRecipeId()); 
    } 

    /** 
    * 
    */ 
    public int hashCode() 
    { 
     int result = 17; 

     result = 37 * result + this.getUserId(); 
     result = 37 * result + this.getRecipeId(); 

     return result; 
    } 
} 

當我做「從UserRating UR其中ur.recipeId =: recipeId和rr.userId =:userId「; GET:初始SessionFactory的創建failed.org.hibernate.HibernateException:無法創建默認的tuplizer [org.hibernate.tuple.component.PojoComponentTuplizer]

任何想法,爲什麼?什麼不見​​了?

+0

你可以張貼其它類的定義 – Saket

+0

連接.............. – Yoav

回答

1

我懷疑你在這裏有一個錯誤的聲明class="mmm.UserRatingId"。你的意思是class="com.mmm.data.UserRatingId"? (更正的標識符類的包名稱)

+0

仍然沒有工作,但好點 – Yoav

+0

你的意思是你有同樣的錯誤? – Saket

+0

謝謝 - 正是這個問題加上java文件中的一些更小的語義。非常感謝 – Yoav

0

嗨我曾經有過相同的錯誤,原因是安全性不允許Domino JVM實例化某些類。

這裏是我的java.policy你可以在JVM \ lib \ security中\ java.policy文件找到可供參考:

// Standard extensions get all permissions by default 
grant codeBase "file:${java.home}/lib/ext/*" { 
permission java.security.AllPermission; 
}; 

// default permissions granted to all domains 
grant { 
// Allows any thread to stop itself using the java.lang.Thread.stop() 
// method that takes no argument. 
// Note that this permission is granted by default only to remain 
// backwards compatible. 
// It is strongly recommended that you either remove this permission 
// from this policy file or further restrict it to code sources 
// that you specify, because Thread.stop() is potentially unsafe. 
// See "http://java.sun.com/notes" for more information. 
permission java.lang.RuntimePermission "stopThread"; 

//允許任何人監聽非特權端口 許可的Java。 net.SocketPermission「localhost:1024-」,「listen」;

//「標準」可以被任何人讀取性的判定

permission java.util.PropertyPermission "java.version", "read"; 
permission java.util.PropertyPermission "java.vendor", "read"; 
permission java.util.PropertyPermission "java.vendor.url", "read"; 
permission java.util.PropertyPermission "java.class.version", "read"; 
permission java.util.PropertyPermission "os.name", "read"; 
permission java.util.PropertyPermission "os.version", "read"; 
permission java.util.PropertyPermission "os.arch", "read"; 
permission java.util.PropertyPermission "file.separator", "read"; 
permission java.util.PropertyPermission "path.separator", "read"; 
permission java.util.PropertyPermission "line.separator", "read"; 

permission java.util.PropertyPermission "java.specification.version", "read"; 
permission java.util.PropertyPermission "java.specification.vendor", "read"; 
permission java.util.PropertyPermission "java.specification.name", "read"; 

permission java.util.PropertyPermission "java.vm.specification.version", "read"; 
permission java.util.PropertyPermission "java.vm.specification.vendor", "read"; 
permission java.util.PropertyPermission "java.vm.specification.name", "read"; 
permission java.util.PropertyPermission "java.vm.version", "read"; 
permission java.util.PropertyPermission "java.vm.vendor", "read"; 
permission java.util.PropertyPermission "java.vm.name", "read"; 

permission java.util.PropertyPermission "javax.realtime.version", "read"; 
permission java.security.AllPermission; 

}; 

// Notes java code gets all permissions 

grant codeBase "file:${notes.binary}/*" { 
permission java.security.AllPermission; 
}; 

grant codeBase "file:${notes.binary}/rjext/*" { 
permission java.security.AllPermission; 
}; 

grant codeBase "file:${notes.binary}/ndext/*" { 
permission java.security.AllPermission; 
}; 

grant codeBase "file:${notes.binary}/xsp/-" { 
permission java.security.AllPermission; 
}; 

grant codeBase "file:${notes.binary}/osgi/-" { 
permission java.security.AllPermission; 
}; 
+0

這裏是一個可能有用的鏈接 - http://stackoverflow.com/q/2049371/532434 – Ritesh