ITeye博客

aniyo的博客

aniyo · 共 212 篇文章

object references an unsaved transient instance

org. hibernate .TransientObjectException: object references an unsaved transient instance - save the transient instance before flushing: 这主要是在ManyToOne级联操作时遇到,比如new了一个新对象,在未保存之前将它保存进了一个新new的对象(也即不是持久态)。 解决办法是在保存或更新之前把这个对象查出来(这样就是一个持久态)。 解决办法是将many-to-one的级联设为: cascade="save-update,persist"

2017-08-08 14:38 · java · 评论(0)

Jave获取当前日期的上一个月最后一天或者下一个月最后一天

public final static Date addMonths(final Date date, final Integer noOfMonths) { Calendar orgCal = GregorianCalendar.getInstance(); orgCal.setTime(date); Calendar newCal = GregorianCalendar.getInstance(); newCal.setTime(date); newCal.set(Calendar.DAY_OF_MONTH, 1); int year = orgCal.get(Calendar.YEAR…

2017-02-08 09:58 · java · 评论(0)

valid date

public final static boolean isValidDate(final String date, final String format) { boolean result = false; try{ Date d = toDate(date, format); String s = DateFormatUtil.format(d, format); result = s.equals(date); } catch (Exception ex) { } return result; } public final static boolean isValidDate(fin…

2017-02-04 16:37 · java · 评论(0)

Row was updated or deleted by another transaction (or unsaved-value mapping was

org.hibernate.StaleObjectStateException: Row was updated or deleted by another transaction (or unsaved-value mapping was incorrect): [com.shkco.adsr3.cbm.vo.CustomerAccountInfo#74225] at org.hibernate.persister.entity.AbstractEntityPersister.check(AbstractEntityPersister.java:2523) at org.hibernate…

2017-02-04 11:41 · java · 评论(0)

hibernate hql return object or list 指定类型

java.lang.ClassCastException: [Ljava.lang.Object; incompatible with com.shkco.adsr3.cbm.vo.ICustomerAccount 看到这错误都知道是数据类型转换不匹配,Object 与ICustomerAccount. DAO 方法原始如下: public List<ICustomerAccount> getListOfCustomerAccount(ISessionContext sessionContext, IClientCentricCustomer clientCentricCustomer) {…

2017-01-25 17:58 · java · 评论(0)

The content of element type "class" must match "(meta*,subselect?,cache?,synchro

The content of element type "class" must match "(meta*,subselect?,cache?,synchronize*,comment?,tuplizer*,(id|composite-id),discriminator?,natural-id?,(version|timestamp)?,(property|many-to-one|one-to-one|component|dynamic-component|properties|any|map|set|list|bag|idbag|array|primitive-array)*,((joi…

2017-01-19 13:44 · SSH · 评论(1)

解决Maven/Ant中OutOfMemory错误

当Maven项目很大,或者你运行诸如 mvn site 这样的命令的时候,maven运行需要很大的内存,在默认配置下,就可能遇到java的堆溢出 exception:OutOfMemoryError set MAVEN_OPTS=-Xms256m -Xmx512m -XX:PermSize=256m -XX:MaxPermSize=384m ANT_OPTS=-Xmx512m -XX:PermSize=128m -XX:MaxPermSize=256m Windows # Go into your Control Panel > System > Advanced System Settin…

2017-01-12 11:06 · java · 评论(0)

Row was updated or deleted by another transaction (or unsaved-value mapping was

Row was updated or deleted by another transaction (or unsaved-value mapping was incorrect) 当在进行操作时,当前version版本与DB中version版本不一致; 有其他用户对当前数据进行了操作。

2016-03-31 16:15 · java · 评论(0)

identifier of an instance of ……was alter from 2 to null

Undefined Error: org.hibernate.HibernateException: identifier of an instance of com.shkco.adsr3.staticdata.vo.ClientGroup was altered from 2 to null List<IClientGroup> clientGroupList = clientGroupService.getAllClientGroup(sessionContext); boolean clientGroupValidate = true; if(clientGroup != null)…

2016-03-29 09:32 · java · 评论(0)

Caused by: org.hibernate.AssertionFailure: collection owner not associated with

Caused by: org.hibernate.AssertionFailure: collection owner not associated with session [13/01/16 11:14:47:779 CST] 00000127 SystemErr R Caused by: org.hibernate.AssertionFailure: collection owner not associated with session: com.shkco.adsr3.cbm.vo.SubAccount.authorizors [13/01/16 11:14:47:779 CST]…

2016-01-13 16:49 · java · 评论(0)

遍历Set集合remove掉不需要的数据,List不能在遍历的时候remove

for(Iterator<IAddress> it=addSet.iterator();it.hasNext();){ IAddress address = it.next(); if(address.getId() != null){ Boolean flag = false; for(IAddress addr : set){ if(addr.getId().equals(address.getId())){ flag = true; break; } } if(!flag){ it.remove(); } } } List遍历的时候不能直接 remove,实现办法是用 iterator…

2015-12-29 15:33 · java · 评论(0)

oracle查询约束

查询约束类型 select distinct constraint_type fromdba_constraints; Type Code Type Description Acts On Level C Check on a table Column O Read Only on a view Object P Primary Key Object R Referential AKA Foreign Key Column U Unique Key Column V Check Option on a view Object 查询各种约束 user_constraints all_const…

2015-12-28 14:45 · java · 评论(0)

Oracle spool格式化数据命令

SQL>set colsep' '; //-域输出分隔符 SQL>set newp none //设置查询出来的数据分多少页显示,如果需要连续的数据,中间不要出现空行就把newp设置为none,这样输出的数据行都是连续的,中间没有空行之类的 SQL>set echo off; //显示start启动的脚本中的每个sql命令,缺省为on SQL> set echo on //设置运行命令是是否显示语句 SQL> set feedback on; //设置显示“已选择XX行” SQL>set feedback off; //回显本次sql命令处理的记录条数,缺省为on即去掉最后的 "已经选择10…

2015-11-26 11:39 · oracle · 评论(0)

Oracle查询被锁的表及被锁的存储过程

查询锁表的Session select sess.sid, sess.serial#, lo.oracle_username, lo.os_user_name, ao.object_name, lo.locked_mode from v$locked_object lo, dba_objects ao, v$session sess where ao.object_id = lo.object_id and lo.session_id = sess.sid; --杀死进程 'sid,serial#' alter system kill session '470,12791'; 查询DDL 操…

2015-11-25 10:27 · oracle · 评论(0)

should be mapped with insert="false" update="false"

Caused by: org.hibernate.MappingException: Repeated column in mapping for entity: com.shkco.adsr3.frontoffice.omos.vo.OSEquOrder column: EXT_SYS_TYPE_ID (should be mapped with insert="false" update="false") 出现这个问题, 一般都是不同的属性映射了相同的字段,所以在hibernate配置文件中找EXT_SYS_TYPE_ID 就可以了,结果这个两个同事一人写了一次,但属性名不一样,字段名相…

2015-04-22 16:23 · java · 评论(0)