Re: [appengine-java] gae不支持事务?

2010-12-16 Thread Liang Ding
The important thing is can't rollback while error occurred.

2010/12/16 EtuO 

> 谢谢大家,只能开启两个事务来解决啦。
>
> 在 2010年12月16日 下午6:11,kartik kudada 写道:
>
> If following operation throws an exception,we can not rollback the first
>> transaction, because it is already committed. What I can think of right now
>> is, you can manually delete it. but it is not the genuine solution.
>>
>> Why don't you create owned relation between these two table?
>> Tell me about your thoughts?
>>
>> Regards,
>> Kartik
>>
>> 2010/12/16 Liang Ding 
>>
>> Hi, kartik.
>>> It works, but how can I rollback the 'first transaction' if the following
>>> operations throws an exception?
>>>
>>> 2010/12/16 kartik kudada 
>>>
 You can not operate on two entities in single transaction unless both
 are entity groups.
 First delete CityNum  in one transaction and then delete ScheduleProcess
  in different transaction,








 2010/12/16 EtuO 

> Caused by: java.lang.IllegalArgumentException: can't operate on
>
> multiple entity groups in a single transaction. found both Element {
>  type: "CityNum"
>  name: "013001"
> }
>  and Element {
>  type: "ScheduleProcess"
>  name: "013001"
> }
>
>at
>
> com.google.appengine.api.datastore.DatastoreApiHelper.translateError(DatastoreApiHelper.java:
> 36)
>at com.google.appengine.api.datastore.DatastoreApiHelper
> $1.convertException(DatastoreApiHelper.java:98)
>at
> com.google.appengine.api.utils.FutureWrapper.get(FutureWrapper.java:
> 69)
>at com.google.appengine.api.datastore.FutureHelper
> $CumulativeAggregateFuture.get(FutureHelper.java:136)
>at com.google.appengine.api.datastore.FutureHelper
> $TxnAwareFuture.get(FutureHelper.java:213)
>at
> com.google.appengine.api.utils.FutureWrapper.get(FutureWrapper.java:
> 67)
>at
>
> com.google.appengine.api.datastore.FutureHelper.getInternal(FutureHelper.java:
> 71)
>at
>
> com.google.appengine.api.datastore.FutureHelper.quietGet(FutureHelper.java:
> 58)
>at
>
> com.google.appengine.api.datastore.DatastoreServiceImpl.get(DatastoreServiceImpl.java:
> 55)
>at
>
> org.datanucleus.store.appengine.RuntimeExceptionWrappingDatastoreService.get(RuntimeExceptionWrappingDatastoreService.java:
> 64)
>... 86 more
>
> 实现类代码:
> /**
> * @see
>
> org.ertuo.taoplugin.facade.TransactionOperation#nestTrans(java.lang.Object[])
> */
>public void nestTrans(Object... objects) {
>String id = (String) objects[0];
>CityNum cn = cityNumDao.get(id);
>ScheduleProcess sp = scheduleDao.get(id);
>cityNumDao.delete(cn);
>scheduleDao.delete(sp);
>logger.info("id[" + id + "]对应的城市和任务删除完毕");
>}
>
> 接口代码:
> /**
>  * 事务性操作接口
>  * @author mo.duanm
>  * @version $Id: TransactionOperation.java, v 0.1 2010-12-16 下午
> 05:22:23 mo.duanm Exp $
>  */
> public interface TransactionOperation {
>
>/**
> * 嵌套事务
> * @param objects
> */
>@Transactional
>public void nestTrans(Object... objects);
>
> --
> You received this message because you are subscribed to the Google
> Groups "Google App Engine for Java" group.
> To post to this group, send email to
> google-appengine-j...@googlegroups.com.
> To unsubscribe from this group, send email to
> google-appengine-java+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/google-appengine-java?hl=en.
>
>
  --
 You received this message because you are subscribed to the Google
 Groups "Google App Engine for Java" group.
 To post to this group, send email to
 google-appengine-j...@googlegroups.com.
 To unsubscribe from this group, send email to
 google-appengine-java+unsubscr...@googlegroups.com
 .
 For more options, visit this group at
 http://groups.google.com/group/google-appengine-java?hl=en.

>>>
>>>
>>>
>>> --
>>> My Blog: http://blog.csdn.net/DL88250
>>> 
>>> Open Source, Open Mind, Open Sight, Open Future!
>>>
>>> --
>>> You received this message because you are subscribed to the Google Groups
>>> "Google App Engine for Java" group.
>>> To post to this group, send email to
>>> google-appengine-j...@googlegroups.com.
>>> To unsubscribe from this group, send email to
>>> google-appengine-java+unsubscr...@googlegroups.com
>>> .
>>> For more options, visit this group at
>>> http://groups.google.com/group/google-appengine-java?hl=en.
>>>
>>
>>  --
>> You received this message because you are subscribed to the Google Groups
>> "Google App Engine for Jav

Re: [appengine-java] gae不支持事务?

2010-12-16 Thread kartik kudada
As article on http://www.keakon.net/article/1843 suggests , you can create
task queue on successful completion of 1st transaction , same can be done
when exception  occurred  in 1st transaction.
I did not try this solution but it seems like good option.

By this way we can achieve atomicity like in banking example .



2010/12/16 风笑雪 

> 不能rollback,但可以roll forward。
> 这篇可能对你有帮助:
> http://www.keakon.net/article/1843
>
> --
> keakon
>
> My blog(Chinese): www.keakon.net
> Blog source code: https://bitbucket.org/keakon/doodle/
>
>
>
> 2010/12/16 EtuO 
>
>> 谢谢大家,只能开启两个事务来解决啦。
>>
>> 在 2010年12月16日 下午6:11,kartik kudada 写道:
>>
>> If following operation throws an exception,we can not rollback the first
>>> transaction, because it is already committed. What I can think of right now
>>> is, you can manually delete it. but it is not the genuine solution.
>>>
>>> Why don't you create owned relation between these two table?
>>> Tell me about your thoughts?
>>>
>>> Regards,
>>> Kartik
>>>
>>> 2010/12/16 Liang Ding 
>>>
>>> Hi, kartik.
 It works, but how can I rollback the 'first transaction' if the
 following operations throws an exception?

 2010/12/16 kartik kudada 

> You can not operate on two entities in single transaction unless both
> are entity groups.
> First delete CityNum  in one transaction and then
> delete ScheduleProcess  in different transaction,
>
>
>
>
>
>
>
>
> 2010/12/16 EtuO 
>
>> Caused by: java.lang.IllegalArgumentException: can't operate on
>>
>> multiple entity groups in a single transaction. found both Element {
>>  type: "CityNum"
>>  name: "013001"
>> }
>>  and Element {
>>  type: "ScheduleProcess"
>>  name: "013001"
>> }
>>
>>at
>>
>> com.google.appengine.api.datastore.DatastoreApiHelper.translateError(DatastoreApiHelper.java:
>> 36)
>>at com.google.appengine.api.datastore.DatastoreApiHelper
>> $1.convertException(DatastoreApiHelper.java:98)
>>at
>> com.google.appengine.api.utils.FutureWrapper.get(FutureWrapper.java:
>> 69)
>>at com.google.appengine.api.datastore.FutureHelper
>> $CumulativeAggregateFuture.get(FutureHelper.java:136)
>>at com.google.appengine.api.datastore.FutureHelper
>> $TxnAwareFuture.get(FutureHelper.java:213)
>>at
>> com.google.appengine.api.utils.FutureWrapper.get(FutureWrapper.java:
>> 67)
>>at
>>
>> com.google.appengine.api.datastore.FutureHelper.getInternal(FutureHelper.java:
>> 71)
>>at
>>
>> com.google.appengine.api.datastore.FutureHelper.quietGet(FutureHelper.java:
>> 58)
>>at
>>
>> com.google.appengine.api.datastore.DatastoreServiceImpl.get(DatastoreServiceImpl.java:
>> 55)
>>at
>>
>> org.datanucleus.store.appengine.RuntimeExceptionWrappingDatastoreService.get(RuntimeExceptionWrappingDatastoreService.java:
>> 64)
>>... 86 more
>>
>> 实现类代码:
>> /**
>> * @see
>>
>> org.ertuo.taoplugin.facade.TransactionOperation#nestTrans(java.lang.Object[])
>> */
>>public void nestTrans(Object... objects) {
>>String id = (String) objects[0];
>>CityNum cn = cityNumDao.get(id);
>>ScheduleProcess sp = scheduleDao.get(id);
>>cityNumDao.delete(cn);
>>scheduleDao.delete(sp);
>>logger.info("id[" + id + "]对应的城市和任务删除完毕");
>>}
>>
>> 接口代码:
>> /**
>>  * 事务性操作接口
>>  * @author mo.duanm
>>  * @version $Id: TransactionOperation.java, v 0.1 2010-12-16 下午
>> 05:22:23 mo.duanm Exp $
>>  */
>> public interface TransactionOperation {
>>
>>/**
>> * 嵌套事务
>> * @param objects
>> */
>>@Transactional
>>public void nestTrans(Object... objects);
>>
>> --
>> You received this message because you are subscribed to the Google
>> Groups "Google App Engine for Java" group.
>> To post to this group, send email to
>> google-appengine-j...@googlegroups.com.
>> To unsubscribe from this group, send email to
>> google-appengine-java+unsubscr...@googlegroups.com
>> .
>> For more options, visit this group at
>> http://groups.google.com/group/google-appengine-java?hl=en.
>>
>>
>  --
> You received this message because you are subscribed to the Google
> Groups "Google App Engine for Java" group.
> To post to this group, send email to
> google-appengine-j...@googlegroups.com.
> To unsubscribe from this group, send email to
> google-appengine-java+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/google-appengine-java?hl=en.
>



 --
 My Blog: http://blog.csdn.net/DL88250
 

Re: [appengine-java] gae不支持事务?

2010-12-16 Thread 风笑雪
不能rollback,但可以roll forward。
这篇可能对你有帮助:
http://www.keakon.net/article/1843

--
keakon

My blog(Chinese): www.keakon.net
Blog source code: https://bitbucket.org/keakon/doodle/



2010/12/16 EtuO 

> 谢谢大家,只能开启两个事务来解决啦。
>
> 在 2010年12月16日 下午6:11,kartik kudada 写道:
>
> If following operation throws an exception,we can not rollback the first
>> transaction, because it is already committed. What I can think of right now
>> is, you can manually delete it. but it is not the genuine solution.
>>
>> Why don't you create owned relation between these two table?
>> Tell me about your thoughts?
>>
>> Regards,
>> Kartik
>>
>> 2010/12/16 Liang Ding 
>>
>> Hi, kartik.
>>> It works, but how can I rollback the 'first transaction' if the following
>>> operations throws an exception?
>>>
>>> 2010/12/16 kartik kudada 
>>>
 You can not operate on two entities in single transaction unless both
 are entity groups.
 First delete CityNum  in one transaction and then delete ScheduleProcess
  in different transaction,








 2010/12/16 EtuO 

> Caused by: java.lang.IllegalArgumentException: can't operate on
>
> multiple entity groups in a single transaction. found both Element {
>  type: "CityNum"
>  name: "013001"
> }
>  and Element {
>  type: "ScheduleProcess"
>  name: "013001"
> }
>
>at
>
> com.google.appengine.api.datastore.DatastoreApiHelper.translateError(DatastoreApiHelper.java:
> 36)
>at com.google.appengine.api.datastore.DatastoreApiHelper
> $1.convertException(DatastoreApiHelper.java:98)
>at
> com.google.appengine.api.utils.FutureWrapper.get(FutureWrapper.java:
> 69)
>at com.google.appengine.api.datastore.FutureHelper
> $CumulativeAggregateFuture.get(FutureHelper.java:136)
>at com.google.appengine.api.datastore.FutureHelper
> $TxnAwareFuture.get(FutureHelper.java:213)
>at
> com.google.appengine.api.utils.FutureWrapper.get(FutureWrapper.java:
> 67)
>at
>
> com.google.appengine.api.datastore.FutureHelper.getInternal(FutureHelper.java:
> 71)
>at
>
> com.google.appengine.api.datastore.FutureHelper.quietGet(FutureHelper.java:
> 58)
>at
>
> com.google.appengine.api.datastore.DatastoreServiceImpl.get(DatastoreServiceImpl.java:
> 55)
>at
>
> org.datanucleus.store.appengine.RuntimeExceptionWrappingDatastoreService.get(RuntimeExceptionWrappingDatastoreService.java:
> 64)
>... 86 more
>
> 实现类代码:
> /**
> * @see
>
> org.ertuo.taoplugin.facade.TransactionOperation#nestTrans(java.lang.Object[])
> */
>public void nestTrans(Object... objects) {
>String id = (String) objects[0];
>CityNum cn = cityNumDao.get(id);
>ScheduleProcess sp = scheduleDao.get(id);
>cityNumDao.delete(cn);
>scheduleDao.delete(sp);
>logger.info("id[" + id + "]对应的城市和任务删除完毕");
>}
>
> 接口代码:
> /**
>  * 事务性操作接口
>  * @author mo.duanm
>  * @version $Id: TransactionOperation.java, v 0.1 2010-12-16 下午
> 05:22:23 mo.duanm Exp $
>  */
> public interface TransactionOperation {
>
>/**
> * 嵌套事务
> * @param objects
> */
>@Transactional
>public void nestTrans(Object... objects);
>
> --
> You received this message because you are subscribed to the Google
> Groups "Google App Engine for Java" group.
> To post to this group, send email to
> google-appengine-j...@googlegroups.com.
> To unsubscribe from this group, send email to
> google-appengine-java+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/google-appengine-java?hl=en.
>
>
  --
 You received this message because you are subscribed to the Google
 Groups "Google App Engine for Java" group.
 To post to this group, send email to
 google-appengine-j...@googlegroups.com.
 To unsubscribe from this group, send email to
 google-appengine-java+unsubscr...@googlegroups.com
 .
 For more options, visit this group at
 http://groups.google.com/group/google-appengine-java?hl=en.

>>>
>>>
>>>
>>> --
>>> My Blog: http://blog.csdn.net/DL88250
>>> 
>>> Open Source, Open Mind, Open Sight, Open Future!
>>>
>>> --
>>> You received this message because you are subscribed to the Google Groups
>>> "Google App Engine for Java" group.
>>> To post to this group, send email to
>>> google-appengine-j...@googlegroups.com.
>>> To unsubscribe from this group, send email to
>>> google-appengine-java+unsubscr...@googlegroups.com
>>> .
>>> For more options, visit this group at
>>> http://groups.google.com/group/google-appengine-java?hl=

Re: [appengine-java] gae不支持事务?

2010-12-16 Thread EtuO
谢谢大家,只能开启两个事务来解决啦。

在 2010年12月16日 下午6:11,kartik kudada 写道:

> If following operation throws an exception,we can not rollback the first
> transaction, because it is already committed. What I can think of right now
> is, you can manually delete it. but it is not the genuine solution.
>
> Why don't you create owned relation between these two table?
> Tell me about your thoughts?
>
> Regards,
> Kartik
>
> 2010/12/16 Liang Ding 
>
> Hi, kartik.
>> It works, but how can I rollback the 'first transaction' if the following
>> operations throws an exception?
>>
>> 2010/12/16 kartik kudada 
>>
>>> You can not operate on two entities in single transaction unless both are
>>> entity groups.
>>> First delete CityNum  in one transaction and then delete ScheduleProcess
>>>  in different transaction,
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>> 2010/12/16 EtuO 
>>>
 Caused by: java.lang.IllegalArgumentException: can't operate on

 multiple entity groups in a single transaction. found both Element {
  type: "CityNum"
  name: "013001"
 }
  and Element {
  type: "ScheduleProcess"
  name: "013001"
 }

at

 com.google.appengine.api.datastore.DatastoreApiHelper.translateError(DatastoreApiHelper.java:
 36)
at com.google.appengine.api.datastore.DatastoreApiHelper
 $1.convertException(DatastoreApiHelper.java:98)
at
 com.google.appengine.api.utils.FutureWrapper.get(FutureWrapper.java:
 69)
at com.google.appengine.api.datastore.FutureHelper
 $CumulativeAggregateFuture.get(FutureHelper.java:136)
at com.google.appengine.api.datastore.FutureHelper
 $TxnAwareFuture.get(FutureHelper.java:213)
at
 com.google.appengine.api.utils.FutureWrapper.get(FutureWrapper.java:
 67)
at

 com.google.appengine.api.datastore.FutureHelper.getInternal(FutureHelper.java:
 71)
at

 com.google.appengine.api.datastore.FutureHelper.quietGet(FutureHelper.java:
 58)
at

 com.google.appengine.api.datastore.DatastoreServiceImpl.get(DatastoreServiceImpl.java:
 55)
at

 org.datanucleus.store.appengine.RuntimeExceptionWrappingDatastoreService.get(RuntimeExceptionWrappingDatastoreService.java:
 64)
... 86 more

 实现类代码:
 /**
 * @see

 org.ertuo.taoplugin.facade.TransactionOperation#nestTrans(java.lang.Object[])
 */
public void nestTrans(Object... objects) {
String id = (String) objects[0];
CityNum cn = cityNumDao.get(id);
ScheduleProcess sp = scheduleDao.get(id);
cityNumDao.delete(cn);
scheduleDao.delete(sp);
logger.info("id[" + id + "]对应的城市和任务删除完毕");
}

 接口代码:
 /**
  * 事务性操作接口
  * @author mo.duanm
  * @version $Id: TransactionOperation.java, v 0.1 2010-12-16 下午
 05:22:23 mo.duanm Exp $
  */
 public interface TransactionOperation {

/**
 * 嵌套事务
 * @param objects
 */
@Transactional
public void nestTrans(Object... objects);

 --
 You received this message because you are subscribed to the Google
 Groups "Google App Engine for Java" group.
 To post to this group, send email to
 google-appengine-j...@googlegroups.com.
 To unsubscribe from this group, send email to
 google-appengine-java+unsubscr...@googlegroups.com
 .
 For more options, visit this group at
 http://groups.google.com/group/google-appengine-java?hl=en.


>>>  --
>>> You received this message because you are subscribed to the Google Groups
>>> "Google App Engine for Java" group.
>>> To post to this group, send email to
>>> google-appengine-j...@googlegroups.com.
>>> To unsubscribe from this group, send email to
>>> google-appengine-java+unsubscr...@googlegroups.com
>>> .
>>> For more options, visit this group at
>>> http://groups.google.com/group/google-appengine-java?hl=en.
>>>
>>
>>
>>
>> --
>> My Blog: http://blog.csdn.net/DL88250
>> 
>> Open Source, Open Mind, Open Sight, Open Future!
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Google App Engine for Java" group.
>> To post to this group, send email to
>> google-appengine-j...@googlegroups.com.
>> To unsubscribe from this group, send email to
>> google-appengine-java+unsubscr...@googlegroups.com
>> .
>> For more options, visit this group at
>> http://groups.google.com/group/google-appengine-java?hl=en.
>>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Google App Engine for Java" group.
> To post to this group, send email to
> google-appengine-j...@googlegroups.com.
> To unsubscribe from this group, send email to
> google-appengine-java+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> 

Re: [appengine-java] gae不支持事务?

2010-12-16 Thread kartik kudada
If following operation throws an exception,we can not rollback the first
transaction, because it is already committed. What I can think of right now
is, you can manually delete it. but it is not the genuine solution.

Why don't you create owned relation between these two table?
Tell me about your thoughts?

Regards,
Kartik

2010/12/16 Liang Ding 

> Hi, kartik.
> It works, but how can I rollback the 'first transaction' if the following
> operations throws an exception?
>
> 2010/12/16 kartik kudada 
>
>> You can not operate on two entities in single transaction unless both are
>> entity groups.
>> First delete CityNum  in one transaction and then delete ScheduleProcess
>>  in different transaction,
>>
>>
>>
>>
>>
>>
>>
>>
>> 2010/12/16 EtuO 
>>
>>> Caused by: java.lang.IllegalArgumentException: can't operate on
>>>
>>> multiple entity groups in a single transaction. found both Element {
>>>  type: "CityNum"
>>>  name: "013001"
>>> }
>>>  and Element {
>>>  type: "ScheduleProcess"
>>>  name: "013001"
>>> }
>>>
>>>at
>>>
>>> com.google.appengine.api.datastore.DatastoreApiHelper.translateError(DatastoreApiHelper.java:
>>> 36)
>>>at com.google.appengine.api.datastore.DatastoreApiHelper
>>> $1.convertException(DatastoreApiHelper.java:98)
>>>at
>>> com.google.appengine.api.utils.FutureWrapper.get(FutureWrapper.java:
>>> 69)
>>>at com.google.appengine.api.datastore.FutureHelper
>>> $CumulativeAggregateFuture.get(FutureHelper.java:136)
>>>at com.google.appengine.api.datastore.FutureHelper
>>> $TxnAwareFuture.get(FutureHelper.java:213)
>>>at
>>> com.google.appengine.api.utils.FutureWrapper.get(FutureWrapper.java:
>>> 67)
>>>at
>>>
>>> com.google.appengine.api.datastore.FutureHelper.getInternal(FutureHelper.java:
>>> 71)
>>>at
>>>
>>> com.google.appengine.api.datastore.FutureHelper.quietGet(FutureHelper.java:
>>> 58)
>>>at
>>>
>>> com.google.appengine.api.datastore.DatastoreServiceImpl.get(DatastoreServiceImpl.java:
>>> 55)
>>>at
>>>
>>> org.datanucleus.store.appengine.RuntimeExceptionWrappingDatastoreService.get(RuntimeExceptionWrappingDatastoreService.java:
>>> 64)
>>>... 86 more
>>>
>>> 实现类代码:
>>> /**
>>> * @see
>>>
>>> org.ertuo.taoplugin.facade.TransactionOperation#nestTrans(java.lang.Object[])
>>> */
>>>public void nestTrans(Object... objects) {
>>>String id = (String) objects[0];
>>>CityNum cn = cityNumDao.get(id);
>>>ScheduleProcess sp = scheduleDao.get(id);
>>>cityNumDao.delete(cn);
>>>scheduleDao.delete(sp);
>>>logger.info("id[" + id + "]对应的城市和任务删除完毕");
>>>}
>>>
>>> 接口代码:
>>> /**
>>>  * 事务性操作接口
>>>  * @author mo.duanm
>>>  * @version $Id: TransactionOperation.java, v 0.1 2010-12-16 下午
>>> 05:22:23 mo.duanm Exp $
>>>  */
>>> public interface TransactionOperation {
>>>
>>>/**
>>> * 嵌套事务
>>> * @param objects
>>> */
>>>@Transactional
>>>public void nestTrans(Object... objects);
>>>
>>> --
>>> You received this message because you are subscribed to the Google Groups
>>> "Google App Engine for Java" group.
>>> To post to this group, send email to
>>> google-appengine-j...@googlegroups.com.
>>> To unsubscribe from this group, send email to
>>> google-appengine-java+unsubscr...@googlegroups.com
>>> .
>>> For more options, visit this group at
>>> http://groups.google.com/group/google-appengine-java?hl=en.
>>>
>>>
>>  --
>> You received this message because you are subscribed to the Google Groups
>> "Google App Engine for Java" group.
>> To post to this group, send email to
>> google-appengine-j...@googlegroups.com.
>> To unsubscribe from this group, send email to
>> google-appengine-java+unsubscr...@googlegroups.com
>> .
>> For more options, visit this group at
>> http://groups.google.com/group/google-appengine-java?hl=en.
>>
>
>
>
> --
> My Blog: http://blog.csdn.net/DL88250
> 
> Open Source, Open Mind, Open Sight, Open Future!
>
> --
> You received this message because you are subscribed to the Google Groups
> "Google App Engine for Java" group.
> To post to this group, send email to
> google-appengine-j...@googlegroups.com.
> To unsubscribe from this group, send email to
> google-appengine-java+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/google-appengine-java?hl=en.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine for Java" group.
To post to this group, send email to google-appengine-j...@googlegroups.com.
To unsubscribe from this group, send email to 
google-appengine-java+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-appengine-java?hl=en.



Re: [appengine-java] gae不支持事务?

2010-12-16 Thread Liang Ding
Hi, kartik.
It works, but how can I rollback the 'first transaction' if the following
operations throws an exception?

2010/12/16 kartik kudada 

> You can not operate on two entities in single transaction unless both are
> entity groups.
> First delete CityNum  in one transaction and then delete ScheduleProcess
>  in different transaction,
>
>
>
>
>
>
>
>
> 2010/12/16 EtuO 
>
>> Caused by: java.lang.IllegalArgumentException: can't operate on
>>
>> multiple entity groups in a single transaction. found both Element {
>>  type: "CityNum"
>>  name: "013001"
>> }
>>  and Element {
>>  type: "ScheduleProcess"
>>  name: "013001"
>> }
>>
>>at
>>
>> com.google.appengine.api.datastore.DatastoreApiHelper.translateError(DatastoreApiHelper.java:
>> 36)
>>at com.google.appengine.api.datastore.DatastoreApiHelper
>> $1.convertException(DatastoreApiHelper.java:98)
>>at
>> com.google.appengine.api.utils.FutureWrapper.get(FutureWrapper.java:
>> 69)
>>at com.google.appengine.api.datastore.FutureHelper
>> $CumulativeAggregateFuture.get(FutureHelper.java:136)
>>at com.google.appengine.api.datastore.FutureHelper
>> $TxnAwareFuture.get(FutureHelper.java:213)
>>at
>> com.google.appengine.api.utils.FutureWrapper.get(FutureWrapper.java:
>> 67)
>>at
>>
>> com.google.appengine.api.datastore.FutureHelper.getInternal(FutureHelper.java:
>> 71)
>>at
>>
>> com.google.appengine.api.datastore.FutureHelper.quietGet(FutureHelper.java:
>> 58)
>>at
>>
>> com.google.appengine.api.datastore.DatastoreServiceImpl.get(DatastoreServiceImpl.java:
>> 55)
>>at
>>
>> org.datanucleus.store.appengine.RuntimeExceptionWrappingDatastoreService.get(RuntimeExceptionWrappingDatastoreService.java:
>> 64)
>>... 86 more
>>
>> 实现类代码:
>> /**
>> * @see
>>
>> org.ertuo.taoplugin.facade.TransactionOperation#nestTrans(java.lang.Object[])
>> */
>>public void nestTrans(Object... objects) {
>>String id = (String) objects[0];
>>CityNum cn = cityNumDao.get(id);
>>ScheduleProcess sp = scheduleDao.get(id);
>>cityNumDao.delete(cn);
>>scheduleDao.delete(sp);
>>logger.info("id[" + id + "]对应的城市和任务删除完毕");
>>}
>>
>> 接口代码:
>> /**
>>  * 事务性操作接口
>>  * @author mo.duanm
>>  * @version $Id: TransactionOperation.java, v 0.1 2010-12-16 下午
>> 05:22:23 mo.duanm Exp $
>>  */
>> public interface TransactionOperation {
>>
>>/**
>> * 嵌套事务
>> * @param objects
>> */
>>@Transactional
>>public void nestTrans(Object... objects);
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Google App Engine for Java" group.
>> To post to this group, send email to
>> google-appengine-j...@googlegroups.com.
>> To unsubscribe from this group, send email to
>> google-appengine-java+unsubscr...@googlegroups.com
>> .
>> For more options, visit this group at
>> http://groups.google.com/group/google-appengine-java?hl=en.
>>
>>
>  --
> You received this message because you are subscribed to the Google Groups
> "Google App Engine for Java" group.
> To post to this group, send email to
> google-appengine-j...@googlegroups.com.
> To unsubscribe from this group, send email to
> google-appengine-java+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/google-appengine-java?hl=en.
>



-- 
My Blog: http://blog.csdn.net/DL88250

Open Source, Open Mind, Open Sight, Open Future!

-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine for Java" group.
To post to this group, send email to google-appengine-j...@googlegroups.com.
To unsubscribe from this group, send email to 
google-appengine-java+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-appengine-java?hl=en.



Re: [appengine-java] gae不支持事务?

2010-12-16 Thread kartik kudada
You can not operate on two entities in single transaction unless both are
entity groups.
First delete CityNum  in one transaction and then delete ScheduleProcess  in
different transaction,








2010/12/16 EtuO 

> Caused by: java.lang.IllegalArgumentException: can't operate on
> multiple entity groups in a single transaction. found both Element {
>  type: "CityNum"
>  name: "013001"
> }
>  and Element {
>  type: "ScheduleProcess"
>  name: "013001"
> }
>
>at
>
> com.google.appengine.api.datastore.DatastoreApiHelper.translateError(DatastoreApiHelper.java:
> 36)
>at com.google.appengine.api.datastore.DatastoreApiHelper
> $1.convertException(DatastoreApiHelper.java:98)
>at
> com.google.appengine.api.utils.FutureWrapper.get(FutureWrapper.java:
> 69)
>at com.google.appengine.api.datastore.FutureHelper
> $CumulativeAggregateFuture.get(FutureHelper.java:136)
>at com.google.appengine.api.datastore.FutureHelper
> $TxnAwareFuture.get(FutureHelper.java:213)
>at
> com.google.appengine.api.utils.FutureWrapper.get(FutureWrapper.java:
> 67)
>at
>
> com.google.appengine.api.datastore.FutureHelper.getInternal(FutureHelper.java:
> 71)
>at
> com.google.appengine.api.datastore.FutureHelper.quietGet(FutureHelper.java:
> 58)
>at
>
> com.google.appengine.api.datastore.DatastoreServiceImpl.get(DatastoreServiceImpl.java:
> 55)
>at
>
> org.datanucleus.store.appengine.RuntimeExceptionWrappingDatastoreService.get(RuntimeExceptionWrappingDatastoreService.java:
> 64)
>... 86 more
>
> 实现类代码:
> /**
> * @see
>
> org.ertuo.taoplugin.facade.TransactionOperation#nestTrans(java.lang.Object[])
> */
>public void nestTrans(Object... objects) {
>String id = (String) objects[0];
>CityNum cn = cityNumDao.get(id);
>ScheduleProcess sp = scheduleDao.get(id);
>cityNumDao.delete(cn);
>scheduleDao.delete(sp);
>logger.info("id[" + id + "]对应的城市和任务删除完毕");
>}
>
> 接口代码:
> /**
>  * 事务性操作接口
>  * @author mo.duanm
>  * @version $Id: TransactionOperation.java, v 0.1 2010-12-16 下午
> 05:22:23 mo.duanm Exp $
>  */
> public interface TransactionOperation {
>
>/**
> * 嵌套事务
> * @param objects
> */
>@Transactional
>public void nestTrans(Object... objects);
>
> --
> You received this message because you are subscribed to the Google Groups
> "Google App Engine for Java" group.
> To post to this group, send email to
> google-appengine-j...@googlegroups.com.
> To unsubscribe from this group, send email to
> google-appengine-java+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/google-appengine-java?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine for Java" group.
To post to this group, send email to google-appengine-j...@googlegroups.com.
To unsubscribe from this group, send email to 
google-appengine-java+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-appengine-java?hl=en.



Re: [appengine-java] gae不支持事务?

2010-12-16 Thread Liang Ding
支持事务,但是不能在同一个事务中操作属于不同实体组的实体。

2010/12/16 EtuO 

> Caused by: java.lang.IllegalArgumentException:* can't operate on
> multiple entity groups in a single transaction*. found both Element {
>  type: "CityNum"
>  name: "013001"
> }
>  and Element {
>  type: "ScheduleProcess"
>  name: "013001"
> }
>
>at
>
> com.google.appengine.api.datastore.DatastoreApiHelper.translateError(DatastoreApiHelper.java:
> 36)
>at com.google.appengine.api.datastore.DatastoreApiHelper
> $1.convertException(DatastoreApiHelper.java:98)
>at
> com.google.appengine.api.utils.FutureWrapper.get(FutureWrapper.java:
> 69)
>at com.google.appengine.api.datastore.FutureHelper
> $CumulativeAggregateFuture.get(FutureHelper.java:136)
>at com.google.appengine.api.datastore.FutureHelper
> $TxnAwareFuture.get(FutureHelper.java:213)
>at
> com.google.appengine.api.utils.FutureWrapper.get(FutureWrapper.java:
> 67)
>at
>
> com.google.appengine.api.datastore.FutureHelper.getInternal(FutureHelper.java:
> 71)
>at
> com.google.appengine.api.datastore.FutureHelper.quietGet(FutureHelper.java:
> 58)
>at
>
> com.google.appengine.api.datastore.DatastoreServiceImpl.get(DatastoreServiceImpl.java:
> 55)
>at
>
> org.datanucleus.store.appengine.RuntimeExceptionWrappingDatastoreService.get(RuntimeExceptionWrappingDatastoreService.java:
> 64)
>... 86 more
>
> 实现类代码:
> /**
> * @see
>
> org.ertuo.taoplugin.facade.TransactionOperation#nestTrans(java.lang.Object[])
> */
>public void nestTrans(Object... objects) {
>String id = (String) objects[0];
>CityNum cn = cityNumDao.get(id);
>ScheduleProcess sp = scheduleDao.get(id);
>cityNumDao.delete(cn);
>scheduleDao.delete(sp);
>logger.info("id[" + id + "]对应的城市和任务删除完毕");
>}
>
> 接口代码:
> /**
>  * 事务性操作接口
>  * @author mo.duanm
>  * @version $Id: TransactionOperation.java, v 0.1 2010-12-16 下午
> 05:22:23 mo.duanm Exp $
>  */
> public interface TransactionOperation {
>
>/**
> * 嵌套事务
> * @param objects
> */
>@Transactional
>public void nestTrans(Object... objects);
>
> --
> You received this message because you are subscribed to the Google Groups
> "Google App Engine for Java" group.
> To post to this group, send email to
> google-appengine-j...@googlegroups.com.
> To unsubscribe from this group, send email to
> google-appengine-java+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/google-appengine-java?hl=en.
>
>


-- 
My Blog: http://blog.csdn.net/DL88250

Open Source, Open Mind, Open Sight, Open Future!

-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine for Java" group.
To post to this group, send email to google-appengine-j...@googlegroups.com.
To unsubscribe from this group, send email to 
google-appengine-java+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-appengine-java?hl=en.



[appengine-java] gae不支持事务?

2010-12-16 Thread EtuO
Caused by: java.lang.IllegalArgumentException: can't operate on
multiple entity groups in a single transaction. found both Element {
  type: "CityNum"
  name: "013001"
}
 and Element {
  type: "ScheduleProcess"
  name: "013001"
}

at
com.google.appengine.api.datastore.DatastoreApiHelper.translateError(DatastoreApiHelper.java:
36)
at com.google.appengine.api.datastore.DatastoreApiHelper
$1.convertException(DatastoreApiHelper.java:98)
at
com.google.appengine.api.utils.FutureWrapper.get(FutureWrapper.java:
69)
at com.google.appengine.api.datastore.FutureHelper
$CumulativeAggregateFuture.get(FutureHelper.java:136)
at com.google.appengine.api.datastore.FutureHelper
$TxnAwareFuture.get(FutureHelper.java:213)
at
com.google.appengine.api.utils.FutureWrapper.get(FutureWrapper.java:
67)
at
com.google.appengine.api.datastore.FutureHelper.getInternal(FutureHelper.java:
71)
at
com.google.appengine.api.datastore.FutureHelper.quietGet(FutureHelper.java:
58)
at
com.google.appengine.api.datastore.DatastoreServiceImpl.get(DatastoreServiceImpl.java:
55)
at
org.datanucleus.store.appengine.RuntimeExceptionWrappingDatastoreService.get(RuntimeExceptionWrappingDatastoreService.java:
64)
... 86 more

实现类代码:
/**
 * @see
org.ertuo.taoplugin.facade.TransactionOperation#nestTrans(java.lang.Object[])
 */
public void nestTrans(Object... objects) {
String id = (String) objects[0];
CityNum cn = cityNumDao.get(id);
ScheduleProcess sp = scheduleDao.get(id);
cityNumDao.delete(cn);
scheduleDao.delete(sp);
logger.info("id[" + id + "]对应的城市和任务删除完毕");
}

接口代码:
/**
 * 事务性操作接口
 * @author mo.duanm
 * @version $Id: TransactionOperation.java, v 0.1 2010-12-16 下午
05:22:23 mo.duanm Exp $
 */
public interface TransactionOperation {

/**
 * 嵌套事务
 * @param objects
 */
@Transactional
public void nestTrans(Object... objects);

-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine for Java" group.
To post to this group, send email to google-appengine-j...@googlegroups.com.
To unsubscribe from this group, send email to 
google-appengine-java+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-appengine-java?hl=en.