JPA annotations = EJB3 annotations = Hibernate注释?(JPA annotations = EJB3 annotations = Hibernate annotations?)
我正在使用JBoss Tools将数据库模式反向工程为POJO。 具体来说,我在hibernatetool ANT任务中使用hbm2java选项。 在hbm2java选项下,您可以指定
ejb3=true
以在POJO中生成EJB3(JPA?)注释。 我的问题是这些注释是否是JPA注释? 或者,更一般地说,JPA注释,Hibernate注释和EJB3注释之间的区别是什么。 它们都基本相同吗?I'm using JBoss Tools to reverse engineer a DB schema into POJO's. Specifically, I'm using the hbm2java option in the hibernatetool ANT task. Under the hbm2java option you can specify
ejb3=true
to have EJB3 (JPA?) annotations generated in your POJO's. My questions is whether these annotations are JPA annotations? Or, more generally, what is the difference between JPA annotations, Hibernate annotations and EJB3 annotations. Are they all essentially the same?
原文:https://stackoverflow.com/questions/7761186
最满意答案
你能做的最好的事情是创建自己的异常并抛出它。
class Exception : public std::exception { public: template< typename... Args > Exception( const std::string& msg, Args... args ); virtual ~Exception() throw (); //! Overrides std::exception virtual const char* what() const throw(); private: //! Log the message_ void log() const; protected: std::string message_; }; template< typename... Args > Exception::Exception( const std::string& msg, Args... args ) : message_( StrFmt::format( msg, args ... ) ) { log(); } class MyException : public Exception { MyException() : Exception( std::string("b must be different from 0") ) }
如果您计划在未捕获的异常上退出程序,则可以安装终止处理程序,在此处重新抛出异常。
static void terminate() { static bool tried_rethrow = false; try { if ( !tried_rethrow ) { tried_rethrow = true; throw; } } catch ( const std::runtime_error& err ) { std::cout << err.what(); } catch ( const Exception& err ) { std::cout << err.what(); } catch ( ... ) { } }
在你的main.cpp中:
std::set_terminate( terminate );
这样就可以在一个地方处理所有未捕获的异常。
The best you can do is to create your own exception and throw that.
class Exception : public std::exception { public: template< typename... Args > Exception( const std::string& msg, Args... args ); virtual ~Exception() throw (); //! Overrides std::exception virtual const char* what() const throw(); private: //! Log the message_ void log() const; protected: std::string message_; }; template< typename... Args > Exception::Exception( const std::string& msg, Args... args ) : message_( StrFmt::format( msg, args ... ) ) { log(); } class MyException : public Exception { MyException() : Exception( std::string("b must be different from 0") ) }
If you further plan to exit the program on uncaught exceptions, it is possible to install a termination handler, where you rethrow the exception.
static void terminate() { static bool tried_rethrow = false; try { if ( !tried_rethrow ) { tried_rethrow = true; throw; } } catch ( const std::runtime_error& err ) { std::cout << err.what(); } catch ( const Exception& err ) { std::cout << err.what(); } catch ( ... ) { } }
and in your main.cpp:
std::set_terminate( terminate );
That way it is possible to handle all uncaught exceptions at a single place.
相关问答
更多-
代码映射上的MSDN页面在要求下的C ++提供有限的支持。 Turns out it was my mistake and not a bug. I had incorrectly put includes in my headers such that almost all .cpp files included all .h files even if they weren't needed. It appears this caused the codemap application to crash ...
-
我怎么能避免以上终止? 通过重新思考你的设计。 你想达到什么目的? 特别是,为什么你需要一个内存中有2700万个条目的查找表? how can i avoid above termination? By rethinking your design. What are you trying to accomplish? In particular, why do you need a lookup table with 27 million entries in memory?
-
其实,我不认为你可以通过这行SET @oldguid = 250006; 到一个mysqlcommand对象(实际上我不知道)。 你应该做的是让你的程序把这些值放在一个局部变量中,然后替换更新查询中的参数。 找到一种方法来混合你的代码和这个: // This line should be outside the While loop Dictionary
variables = new Dictionary (); ... -
错误消息C ++(Error Message C++)[2022-05-03]
你忘记了一个分号: templateclass btree_iterator { }; ^ You forgot a semicolon: template class btree_iterator { }; ^ -
芹菜抛出长的错误信息(Celery throwing long error message)[2023-09-15]
在github上有一个公开的问题,其中发现了相同的操作系统错误: https://github.com/celery/py-amqp/issues/130 有人在关于该问题的评论中建议, 通过将amqp版本降级到2.1.3来暂时解决该问题 为降级而采取的步骤: 使用$ pip uninstall amqp 。 使用$ pip install -Iv amqp==2.1.3 。 There is an open issue on github where the same OS-error has been ... -
C ++ / CLI中的超级基本OpenFileDialog抛出错误(Super Basic OpenFileDialog in C++/CLI is throwing error)[2022-09-07]
它要求你放: [STAThread] 在你的主要功能上。 这意味着clr应该启动单线程公寓。 Windows窗体不能在MTA(多线程单元)中工作。 进一步阅读: http : //blogs.msdn.com/b/jfoscoding/archive/2005/04/07/406341.aspx It's asking for you to put: [STAThread] on your main function. This means that clr should start a Single Th ... -
如果是用于验证目的,我会向您推荐优秀的Fluent Validation库。 从网站引用: using FluentValidation; public class CustomerValidator: AbstractValidator
{ public CustomerValidator() { RuleFor(customer => customer.Surname).NotEmpty(); RuleFor(customer => customer.Foren ... -
你能做的最好的事情是创建自己的异常并抛出它。 class Exception : public std::exception { public: template< typename... Args > Exception( const std::string& msg, Args... args ); virtual ~Exception() throw (); //! Overrides std: ...
-
这里可能有用的一种方法是改变调用您明确允许失败的代码的方式,使其看起来根本不像try / catch块。 例如,您可以编写一个执行错误报告的辅助方法,并使用表示为lambdas的操作来调用它: void InvokeFailSafe(Action action, Action
onFailure = null) { try { action(); } catch (Exception e) { if (onFailure != null) ... -
尝试使用szNotes:= SQL.FieldByName('Notes')。AsWideString; try to use szNotes := SQL.FieldByName('Notes').AsWideString;