Hibernate的提示错误
Caused by: org.hibernate.HibernateException:
identifier of an instance of ... is alterde from 1 to 5
是下面这段代码报的错
public void insertRelation(Object obj,List list1)
{
Object obj= new Object ();
for (int i = 0; i < list1.size(); i++)
{
service.insert(obj);
}
}
这个错误是由于在一个事务中更新了主键,而主键是不能被更新的.
这段代码的错误在Object obj= new Object ();
这句代码放在for循环的外面,因此每次循环插入的时候,Hibernate认为只是一个对象,主键被更新,因此报错,如果放在for循环里面,就正常了,每次插入都是一个新的对象.
正确的代码如下
public void insertRelation(Object obj,List list1)
{
for (int i = 0; i < list1.size(); i++)
{
Object obj= new Object ();
service.insert(obj);
}
}
分享到:
相关推荐
- ADD: Add TFlexPanel.InvalidateControl virtual method which calls from TFlexControl.Invalidate and can be overriden (it is possible now to catch all object invalidation calls). - FIX: The TFlexPanel....
数字对象标识符(Digital Object Identifier,简称DOI)是一种持久性标识符,用于唯一地标识数字资源,如学术文章、数据集等。DOI系统由国际DOI基金会管理,并在出版界广泛采用。随着数字资源的增加以及对资源描述的...
A FilterChain is an object provided by the servlet container to the developer giving a view into the invocation chain of a filtered request for a resource. FilterConfig - interface javax.servlet....
This research work is carried out within the framework of the PRAXITELE project which aims to develop a future-oriented urban transportation system based on a fleet of electric computer-driven ...
An isolation level determines the degree to which data is isolated for use by one process and guarded against interference from other processes. Prior to SQL Server 7.0, REPEATABLE READ and ...
If you currently work with VCLZip 2.X with TBlobStreams or some other type of streams, you can either define your own TkpBlobStream for instance which inherits from TkpHugeStream, or use the ...
The "Identifier Case Sensitive" check box, which enables case-sensitive processing of database object identifier names, is added to MySQL Server Options The documentation generation for Enum members ...
Each index row in node pages contains an index key (or set of keys for a composite index) and a pointer to a page at the next level for which the first key value is the same as the key value in the ...
Wifi (802.11) In a wireless LAN, wireless users transmit/receive packets to/from an base station (i.e., wireless access point) within a radius of few tens of meters. The base station is typically ...
* when demuxing subtitle files, the number of captions is added to the filename * timestamp derived FPS is used for gap checking instead of video bitstream FPS * fixed: 44.1khz AC3 encoding was still ...
Chapter 5, Import, Export, and Module Data, covers the most used Odoo data file formats—XML and CSV—the external identifier concept, how use to data file in modules, and data import/export ...
- **`extend(event)`**: Extends the functionality of an event object. - **`findElement(event, tagName)`**: Finds the first element under the target of an event that matches the specified `tagName`. -...
All resources, including files and Registry keys, that one user has access to, the other will as well.Another instance where duplicate SIDs can cause problems is where there is removable media ...
错误:L6238E:os_cpu_a.o(subr) contains invalid call from '~PRES8 (The user did not require code to preserve 8-byte aligment of 8-byte data objects)' function to 'REQ8 (Codewas permitted to depend on ...
The user can enter a number to each of the two textinput boxes, then click/tap either of the four images of mathematical operators. Once clicked, it should display a correct answer on the screen. 1. ...
1987IEEE Guide for Control of Hydroelectric Power Plants
2 Octet - Length in octets (in network byte order) of an extension identifier and contents. If 0x0000, then no further extensions exist and the next octet is the start of the Initialization Vector...