简体   繁体   English

如何在Oracle adf中通过SQL设置实体/视图对象属性的默认值?

[英]How to set default value of entity/view object's attribute via SQL in Oracle adf?

I want to set default value of ID attribute in view object via a sql query , ie : 我想通过sql查询在视图对象中设置ID属性的默认值,即:

SELECT (MAX(DEPTID) + 1) 
FROM DEPARTMENT;

so that I can use it as an auto-increment feature in oracle-adf. 这样我就可以将其用作oracle-adf中的自动增量功能。 I have used sequences for it too via java but it doesn't fulfill my requirement. 我也通过Java使用了序列,但是不能满足我的要求。 I also tried the SQL method myself, but when I deploy the form the page is returned blank and when I run app-module it doesn't work as well. 我也亲自尝试了SQL方法,但是当我部署表单时,页面返回空白,而当我运行应用程序模块时,它也无法正常工作。

该图显示了我正在实现的SQL方法

I tested this exact setup on JDeveloper 12.2.1.3 (current production) and it works fine. 我在JDeveloper 12.2.1.3(当前生产)上测试了此确切的设置,并且工作正常。 The BC Tester and Rendered page both show the incremented max dept id. BC测试器和“渲染”页面都显示了递增的最大部门ID。

However, the "Transient Type" for me was set to "Number" if I set the Attribute type to BigDecimal and BigInt if I selected BigInteger. 但是,如果我将属性类型设置为BigDecimal,并且将BigIntger设置为BigInt,则对我来说“瞬态类型”将设置为“数字”。 I notice in your screen shot it shows the type as "$none$" - perhaps this is the issue? 我注意到在您的屏幕截图中,该类型显示为“ $ none $”-也许是问题所在?

Also, if you are incrementing by a whole number, why choose BigDecimal for the Type? 另外,如果要递增整数,为什么要为Type选择BigDecimal? Shouldn't it be Integer or Big Integer? 它不应该是Integer或Big Integer吗?

Also, in case you don't know - it's a recommended practice to put the EOs, VOs, Links, Assocs, etc. into separate packages to make it easier to read, etc. Go to Tools > Preferences > ADF Business Components > packages. 另外,如果您不知道-建议将EO,VO,链接,Assoc等放入单独的程序包中,以使其易于阅读等。转到“工具”>“首选项”>“ ADF业务组件”>“程序包”。 。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM