HANA: View refactoring failed due to error 'NullPointerException'

本文介绍了解决HANA Studio中进行视图重构时出现的错误问题,包括错误的具体表现、产生的原因及如何通过SQL命令清除系统残留的无效条目来解决问题。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

If you ignore the prompt and continue the refactoring, the following error information will popup:
Error occured during the refactoring of <view_name>java.lang.NullPointerException   
at com.sap.ndb.studio.modeler.job.type.copymodels.MoveModelsHandler.updateReferences(MoveModelsHandler.java)   
at com.sap.ndb.studio.modeler.job.type.copymodels.MoveModelsHandler.moveModels(MoveModelsHandler.java)   
at com.sap.ndb.studio.modeler.job.type.copymodels.RefactorModelsJob.moveModels(RefactorModelsJob.java)   
at com.sap.ndb.studio.modeler.job.type.copymodels.RefactorModelsJob.refactor(RefactorModelsJob.java)   
at com.sap.ndb.studio.modeler.job.type.copymodels.RefactorModelsJob.run(RefactorModelsJob.java)   
at org.eclipse.core.internal.jobs.Worker.run(Worker.java)


Environment
HANA database 1.0 all releases


Reproducing the Issue
On HANA Studio, find out your view, Right click it -> Refactor -> Move, in popup window, choose the target package that you would move to, then click "Next".


Cause
This problem is usually caused by one of the following reasons:
  1. When you deleted the referential view, something went wrong, so this object was not permanently deleted from HANA database, but only was marked for deletion and can't be shown in Navigator anymore.
  2. When you deleted the referencing relationship, something went wrong, so this relationship was not permanently deleted from HANA database and can't be shown in Modeler perspective.


Resolution
If you make sure that the referential view won't be used anymore, you need firstly check if the referential view or the referencing relationship is still existing in system views. You can use the following SQL statements for checking:
SELECT * FROM "_SYS_REPO"."INACTIVE_OBJECT" WHERE package_id = '<package name>' AND object_name = '<referential view>';
SELECT * FROM "_SYS_REPO"."INACTIVE_OBJECTCROSSREF" WHERE from_package_id = '<package name>' AND from_object_name = '<referential view>';
Delete the unwanted entries using SQL commands:
DELETE FROM "_SYS_REPO"."INACTIVE_OBJECT" WHERE package_id = '<package name>' AND object_name = '<referential view>';
DELETE FROM "_SYS_REPO"."INACTIVE_OBJECTCROSSREF" WHERE from_package_id = '<package name>' AND from_object_name = '<referential view>'; 
Then you can retry to refactor the primary view.
### 关于 `boost::hana::type_c` 的用法与实现 #### 什么是 `boost::hana::type_c` `boost::hana::type_c<T>` 是 Boost.Hana 库中的一个工具,用于表示编译期常量类型的字面值。它允许开发者在模板元编程中更方便地操作类型,而无需显式实例化对象。 其核心功能可以总结为两点: 1. 提供一种简洁的方式来表达某个特定的类型作为编译期常量。 2. 支持与其他 Hana 数据结构和算法无缝集成[^4]。 --- #### 使用场景 以下是几个常见的使用场景: 1. **定义类型列表** 当需要创建一个包含多个类型的集合时,可以直接利用 `hana::tuple_t` 和 `hana::type_c` 来构建。 ```cpp #include <boost/hana.hpp> namespace hana = boost::hana; constexpr auto types = hana::make_tuple( hana::type_c<int>, hana::type_c<double>, hana::type_c<std::string> ); ``` 这里通过 `hana::type_c` 将不同类型封装成一个可迭代的对象 `types`,便于后续处理[^5]。 2. **基于类型的分派** 利用 `hana::if_` 或其他控制流机制可以根据输入类型执行不同的逻辑分支。 ```cpp template<typename T> void process() { hana::if_(hana::equal(hana::typeid_(std::declval<T>()), hana::type_c<int>), []{ std::cout << "Processing int\n"; }, []{ std::cout << "Processing something else\n"; } ); } process<int>(); // 输出: Processing int process<double>(); // 输出: Processing something else ``` 3. **静态断言** 可以用来验证某些条件是否满足指定的要求。 ```cpp static_assert(hana::is_a<hana::type_tag, hana::type_c<float>>{}, "Not a type!"); ``` --- #### 实现细节分析 虽然具体的内部实现可能较为复杂,但从高层次来看,`hana::type_c<T>` 主要依赖以下几个概念来完成工作: 1. **Tag Dispatching**: 它本质上是一个带有特化的模板类,能够区分不同种类的数据(如整数、浮点数或自定义类型)。这种设计使得我们可以针对每种情况提供专门的行为。 ```cpp struct type_tag {}; template<typename T> struct type : type_tag { using value_type = T; }; ``` 2. **constexpr Support**: 现代 C++ 中引入了更多的编译时常量支持能力,这使许多原本运行阶段才能完成的操作得以提前到编译期间解决。因此,在实际应用过程中可以看到大量涉及计算或者判断的动作都发生在编译器解析源码的时候而不是程序真正被执行之后[^6]。 3. **Integration with Other Components**: 如前所述,除了单独作用外,该组件还经常和其他部分配合起来共同发挥作用。比如前面提到过的 tuple 构造以及各种各样的转换函数等等都是如此。 --- ```cpp #include <boost/hana/all.hpp> namespace hana = boost::hana; // Example demonstrating how 'type_c' works alongside other features. template<typename... Ts> struct TypeList {}; int main(){ constexpr auto list_of_types = hana::make<Tuple>( hana::type_c<TypeList<>>, hana::type_c<TypeList<int>>, hana::type_c<TypeList<char,float>> ); for(auto&& t : list_of_types){ if constexpr(decltype(t)::value_type{} == TypeList<>{}) std::cout<<"Empty typelist found.\n"; else{ // More complex processing... } } } ``` 上述例子展示了如何组合多种技术形成强大的解决方案框架。 ---
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值