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.
相关问答
更多Visual Studio 2013 - c ++代码映射错误消息(Visual Studio 2013 - c++ code map error message)
在C ++程序中的错误消息(Error message while in C++ program)
MySql“SET @variable”在C#代码中引发致命错误(MySql “SET @variable” throwing Fatal Error in C# code)
错误消息C ++(Error Message C++)
芹菜抛出长的错误信息(Celery throwing long error message)
C ++ / CLI中的超级基本OpenFileDialog抛出错误(Super Basic OpenFileDialog in C++/CLI is throwing error)
错误消息与抛出异常C#ASP.Net(Error message vs. throwing exception C# ASP.Net)
C ++从代码中的不同位置抛出相同的错误消息(C++ Throwing same error message from different places in code)
如何明确不抛出异常?(How to be explicit about NOT throwing an exception?)
“获取类型超出范围”错误消息抛出(“fetch type out of range” error message throwing)
相关文章
更多Spring Project Annotations
Hibernate创建sessionFactory null
jpa与hibernate注解混合使用
【第八章】 对ORM的支持 之 8.4 集成JPA ——跟我学spring3
刚开始学hibernate第一个小程序就出了问题,希望指点
hibernate中基于annotation(注解)的many2many双向
hibernate中基于annotation(注解)的one2Many双向
《EJB 3.0从入门到精通》扫描版[PDF]
Hibernate Search(基于version3.4)--第五章Querying
Hibernate 注释方式示例
最新问答
更多获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)
如何通过引用返回对象?(How is returning an object by reference possible?)
矩阵如何存储在内存中?(How are matrices stored in memory?)
每个请求的Java新会话?(Java New Session For Each Request?)
css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)
无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)
xcode语法颜色编码解释?(xcode syntax color coding explained?)
在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)
从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)
从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))
Copyright ©2023 peixunduo.com All Rights Reserved.粤ICP备14003112号
本站部分内容来源于互联网,仅供学习和参考使用,请莫用于商业用途。如有侵犯你的版权,请联系我们(neng862121861#163.com),本站将尽快处理。谢谢合作!