Java 休眠、设置键、CompositeUserType和SQL过程

Java 休眠、设置键、CompositeUserType和SQL过程,java,oracle,hibernate,hibernate-mapping,Java,Oracle,Hibernate,Hibernate Mapping,我在使用Hibernate和自定义CompositeUserType键将非空集返回到对象时遇到一些问题 我在这里简化了一组表和视图: create table lang (lang_id,lang_cd); create table article (art_id,...); create table article_lang (art_id, lang_id,title,...); create view article_lang_vw (select * from article

我在使用Hibernate和自定义CompositeUserType键将非空集返回到对象时遇到一些问题

我在这里简化了一组表和视图:

create table lang (lang_id,lang_cd);  
create table article (art_id,...);  
create table article_lang (art_id, lang_id,title,...);  
create view article_lang_vw (select * from article join article_lang on art_id);  
create table authors(user_id,...);  
create table article_authors(art_id,lang_id,user_id);  
和数据库功能:

create or replace procedure addarticle(title,art_id,lang_id) ...
create or replace procedure updatearticle(title,art_id,lang_id)..
create or replace procedure delarticle(art_id,lang_id)..
create or replace procedure addarticleauthor(user_id,art_id,lang_id)...
create or replace procedure delarticleauthor(user_id,art_id,lang_id)...
为了使用这些函数完成映射,我必须实现CompositeUserType,所以现在我有如下Java类:

class ProcedureGenerator implements PostInsertIdentityGenerator ...
class Language { int lang_id }  
class ArticleLangPKType implements CompositeUserType { //implemented methods }
class ArticleLangPK { int art_id; Language l; } 
class Article { ArticleLangPK id; String title; Set<Author> authors; }  
class Author { int user_id; String name; }
我想要一个作者列表或一组作者。但无法确定如何在*.hbm.xml文件中映射此部分。它现在看起来像这样:

<class name="Author" mutable="false">
    <id name="user_id"/>
    <property name="name"/>
</class>
<class name="Article">
    <id name="id" type="ArticleLangPKType">
        <column name="art_id"/>
        <column name="lang_id"/>
        <generator class="ProcedureGenerator"/>
    </id>
    <property name="title"/>
    <set name="authors" table="article_authors">
        <key> <!--  <key type="ArticleLangPKType"> -->
            <column name="art_id"/>
            <column name="lang_id"/>
        </key>
        <many-to-many class="Author" table="article_authors" unique="true"/>
<!-- addauthor, delauthor sql here some how -->
    </set>
    <sql-insert callable="true">{call addarticle(?,?,?)}</sql-insert>
    <sql-update callable="true">{call updatearticle(?,?,?)}</sql-update>
    <sql-delete callable="true">{call adddelete(?,?)}</sql-delete>
</class>
但是当我运行session.loadArticle.class时,我知道一篇文章的pk有作者,我得到的设置大小为零。否则,使用Hibernate插入、更新和删除都没有问题,但现在我被难住了。在我看来,这似乎表明我的ArticleLangPKType存在问题

你有什么想法来完成这个吗?为什么我的电视机总是0码?如何使用本文提供的集合和SQL过程保存作者?冬眠适合我吗?我需要休息一下才能看清楚吗


提前谢谢

没关系,我确实需要长时间休息。我的ArticleLangPK没有正确覆盖hashCode和Equals。现在我们来看看如何正确调用另外两个存储过程