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
最满意答案
您的外设的蓝牙设备地址是公共的还是随机的静态地址? 如果是随机的,则需要将选项 - -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" ) ...
-
用于RBL的Postfix白名单(Postfix Whitelist for RBL)[2024-02-18]
好吧,经过很多时间,我发现我的错误! 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 ... -
Phonegap无法使用白名单(Phonegap can't use whitelist)[2024-02-05]
@Arefi, 在Phonegap上没有CORS,也不适用。 CORS适用于webbrowsers和服务器 您可以通过以下两种方式解决问题。 在config.xml添加一个版本,如下所示:您可以添加白名单 ,这是Cordova / Phongap 4.0.0之后的正确方法(或者如果您没有使用版本 - 就像您一样) 您可以通过阅读Phonegap Build Whiteelist Guide来添加白 名 ... -
SQL命令不起作用(SQL command isn't working)[2022-07-05]
对于不返回数据的原始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()命令?(Is it possible [how?] to blacklist & whitelist shell_exec() commands?)[2022-07-15]
如果是关于某些脚本 - 只是不要将用户输入传递给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 ...