首页 \ 问答 \ hibernate中的双向映射(Bidirectional mapping in hibernate)

hibernate中的双向映射(Bidirectional mapping in hibernate)

我有两个表,引号和quotation_item。 他们之间有一对多关系。 我的要求是当我执行quotation.setQuotationItem(set) ,应该删除映射到引用的旧quotationItem,并且set中的quotationItems应该映射到引号。

/ * **我的报价pojo就像* ** * /

    public class Quotation {
    int quotationId;
    String code;
    String clientName;
    Set<QuotationItem> quotationItem=new HashSet<QuotationItem>();
    //getter and setter
    }

/ * ** QuotationItem POJO * *** /

    public class QuotationItem extends Quotation{
    int id;
    Quotation quotation;
    String itemName;
    int rate;
    int qty;
    //getter and setter
    }

/ * * Quotation.hbm * ** * **** /

    <hibernate-mapping>
    <class name="com.paramatrix.pojo.Quotation" table="quotation" >
    <id name="quotationId" type="int" column="quotation_id">
    <generator class="native" />
    </id>
    <property name="code" column="code" type="string" />
    <property name="clientName" column="client_name" type="string" />
    <set name="quotationItem" table="quotation_item" cascade="save-update" inverse="true">
    <key>
    <column name="quotation_id" not-null="true" />
    </key>
    <one-to-many class="com.paramatrix.pojo.QuotationItem" />
    </set>
    </class>
    </hibernate-mapping>

/ ** QuotationItem.hbm * ** * ** /

    <class name="com.paramatrix.pojo.QuotationItem" table="quotation_item" dynamic-insert="true">
    <id name="id" type="int" column="id">
    <generator class="native" />
    </id>
    <many-to-one name="quotation" class="com.paramatrix.pojo.Quotation" >
    <column name="quotation_id" not-null="true" />
    </many-to-one>
    <property name="itemName" column="item_name" type="string" />
    <property name="rate" column="rate" type="int" />
    <property name="qty" column="qty" type="int" />
    </class>

我的表格结构与报价类似

quotation_id code client_name

我的Quotation_item表格结构

id quotation_id item_name rate qty


I have two tables, quotation and quotation_item. There is one to many relationship them. My requirement is when I do quotation.setQuotationItem(set), old quotationItem mapped to quotation should get removed and quotationItems in set should get mapped against quotation.

/*** My Quotation pojo is like ****/

    public class Quotation {
    int quotationId;
    String code;
    String clientName;
    Set<QuotationItem> quotationItem=new HashSet<QuotationItem>();
    //getter and setter
    }

/*** QuotationItem POJO ****/

    public class QuotationItem extends Quotation{
    int id;
    Quotation quotation;
    String itemName;
    int rate;
    int qty;
    //getter and setter
    }

/** Quotation.hbm ********/

    <hibernate-mapping>
    <class name="com.paramatrix.pojo.Quotation" table="quotation" >
    <id name="quotationId" type="int" column="quotation_id">
    <generator class="native" />
    </id>
    <property name="code" column="code" type="string" />
    <property name="clientName" column="client_name" type="string" />
    <set name="quotationItem" table="quotation_item" cascade="save-update" inverse="true">
    <key>
    <column name="quotation_id" not-null="true" />
    </key>
    <one-to-many class="com.paramatrix.pojo.QuotationItem" />
    </set>
    </class>
    </hibernate-mapping>

/** QuotationItem.hbm ******/

    <class name="com.paramatrix.pojo.QuotationItem" table="quotation_item" dynamic-insert="true">
    <id name="id" type="int" column="id">
    <generator class="native" />
    </id>
    <many-to-one name="quotation" class="com.paramatrix.pojo.Quotation" >
    <column name="quotation_id" not-null="true" />
    </many-to-one>
    <property name="itemName" column="item_name" type="string" />
    <property name="rate" column="rate" type="int" />
    <property name="qty" column="qty" type="int" />
    </class>

My tables structure is like for Quotation

quotation_id code client_name

My table structure for Quotation_item

id quotation_id item_name rate qty


原文:https://stackoverflow.com/questions/22334632
更新时间:2023-04-25 14:04

最满意答案

您的外设的蓝牙设备地址是公共的还是随机的静态地址? 如果是随机的,则需要将选项 - -random添加到lewladd命令中。

lewlsz命令返回可以存储在白名单中的最大设备数; 不是目前的大小。


Is the Bluetooth Device address of your peripheral a public or random static address? If it's a random, you need to add the option - -random to the lewladd command.

The lewlsz command returns the maximum number of devices that can be stored in the white list; not the current size.

相关问答

更多
  • 将此代码插入到主题的functions.php中。 它会检查你是否登录。 接下来,如果当前页面不是主页或首页,它会将用户重定向到登录页面。 并且您不需要其他插件重定向,因此请在测试此代码之前禁用任何强制登录插件。 function logged_in_only() { if ( ! is_user_logged_in() ) { if( !is_home() || !is_front_page() ) auth_redirect(); } } add_ ...
  • 最好为此使用javascript框架,并仍使用单个index.html文件。 我遇到的最佳做法是使应用程序不是多个html文件。 有许多框架可以实现这一点,最好的文档是jquerymobile。 在javascript文件中使用JQueryMobile,您将使用jquerymobile检查page1 div何时加载,然后运行.load代码。 JQueryMobile有不同的事件,它注意到...在这种情况下,在页面启动(pageinit)之前,你想运行加载东西来从其他网站获取内容。 $( "#page1" ) ...
  • 好吧,经过很多时间,我发现我的错误! main.cf: smtpd_recipient_restrictions = .... check_client_access regexp:/etc/postfix/whitelist_recipient, .... reject_rbl_client dnsbl.sorbs.net, .... 它不是哈希值:它必须是正则表达式: Ok, after a lot of time, I found my mistake! m ...
  • 根据文件 : extensions:文件扩展名的白名单。 {null,Array} extensions选项期待一个数组。 尝试这个: extensions: [ 'jpg', 'jpeg' ] 但请记住,这只是通过扩展过滤 - 没有什么阻止我发送你myHorribleVirus.exe.jpg ;-) According to the docs: extensions: Whitelist for file extension. {null, Array} the extensions ...
  • 您的外设的蓝牙设备地址是公共的还是随机的静态地址? 如果是随机的,则需要将选项 - -random添加到lewladd命令中。 lewlsz命令返回可以存储在白名单中的最大设备数; 不是目前的大小。 Is the Bluetooth Device address of your peripheral a public or random static address? If it's a random, you need to add the option - -random to the lewladd ...
  • Ag.vim已被弃用; 你应该考虑回到使用Ack.vim。 Ack.vim的维护者愿意支持Ag社区。 :AckFromSearch允许传递额外的选项,如-G。 首先必须将Ack.vim配置为使用Ag,方法是将其添加到.vimrc: let g:ackprg = 'ag --vimgrep' 然后,你可以这样做:AckFromSearch如下: :AckFromSearch -G '.*py' 自从回到Ack.vim插件后,我经常使用这个功能,并在vim中映射了* to:AgFromSearch。 A ...
  • 尝试使用以下内容将白名单目录更改为您的phpunit: ./src ./src/*/*Bundle/Resources ./src/*/*Bundle/Tests ./src/*/Bundle/*Bundle/Res ...
  • @Arefi, 在Phonegap上没有CORS,也不适用。 CORS适用于webbrowsers和服务器 您可以通过以下两种方式解决问题。 在config.xml添加一个版本,如下所示: 您可以添加白名单 ,这是Cordova / Phongap 4.0.0之后的正确方法(或者如果您没有使用版本 - 就像您一样) 您可以通过阅读Phonegap Build Whiteelist Guide来添加白 名 ...
  • 对于不返回数据的原始SQL查询,请使用execSQL()而不是rawQuery() 。 rawQuery()只编译SQL但不运行它。 execSQL()编译并运行它。 Use execSQL() and not rawQuery() for raw SQL queries that don't return data. rawQuery() just compiles the SQL but does not run it. execSQL() both compiles and runs it.
  • 如果是关于某些脚本 - 只是不要将用户输入传递给shell_exec参数,请在某些参数匹配某个值时调用它 if ($_GET['cmd'] === 'whois') { shell_exec('whois whatever'); } 如果它是关于托管类型,那么您应该使用操作系统权限限制对数据的访问。 因此用户可以调用shell_exec('rm -rf /')但不会发生任何事情。 If it's about some script — just don't pass user input into ...

相关文章

更多

最新问答

更多
  • 获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)
  • 如何通过引用返回对象?(How is returning an object by reference possible?)
  • 矩阵如何存储在内存中?(How are matrices stored in memory?)
  • 每个请求的Java新会话?(Java New Session For Each Request?)
  • css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)
  • 无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)
  • xcode语法颜色编码解释?(xcode syntax color coding explained?)
  • 在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)
  • 从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)
  • 从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))
  • 西安哪有PLC可控制编程的培训
  • 在Entity Framework中选择基类(Select base class in Entity Framework)
  • 在Android中出现错误“数据集和渲染器应该不为null,并且应该具有相同数量的系列”(Error “Dataset and renderer should be not null and should have the same number of series” in Android)
  • 电脑二级VF有什么用
  • Datamapper Ruby如何添加Hook方法(Datamapper Ruby How to add Hook Method)
  • 金华英语角.
  • 手机软件如何制作
  • 用于Android webview中图像保存的上下文菜单(Context Menu for Image Saving in an Android webview)
  • 注意:未定义的偏移量:PHP(Notice: Undefined offset: PHP)
  • 如何读R中的大数据集[复制](How to read large dataset in R [duplicate])
  • Unity 5 Heighmap与地形宽度/地形长度的分辨率关系?(Unity 5 Heighmap Resolution relationship to terrain width / terrain length?)
  • 如何通知PipedOutputStream线程写入最后一个字节的PipedInputStream线程?(How to notify PipedInputStream thread that PipedOutputStream thread has written last byte?)
  • python的访问器方法有哪些
  • DeviceNetworkInformation:哪个是哪个?(DeviceNetworkInformation: Which is which?)
  • 在Ruby中对组合进行排序(Sorting a combination in Ruby)
  • 网站开发的流程?
  • 使用Zend Framework 2中的JOIN sql检索数据(Retrieve data using JOIN sql in Zend Framework 2)
  • 条带格式类型格式模式编号无法正常工作(Stripes format type format pattern number not working properly)
  • 透明度错误IE11(Transparency bug IE11)
  • linux的基本操作命令。。。