Forum Stats

  • 3,851,423 Users
  • 2,263,974 Discussions


Access Data from Database in Bean

ChristianM0147 Member Posts: 37 Red Ribbon

Hello fellow programmers.

Im currently on the JDeveloper Version

Can somebody please explain me how to access data from the Database in a bean?

I have an Application with 2 Components. An af:inputText and af:selectOneChoice. The af:inputText has an valueChangeListener that triggers a Method in a backing Bean with request scope. The af:inputText has also a binding to that bean.

I want to access my Database table with the value given in the af:inputText in the valueChangeListener Method. I already created the EntityObject and ViewObject for that table and I know how to access the value inserted in the af:inputText but i dont know how to access the ViewObject/EntityObject in the bean.

I want something like: "Select city from citys where postcode = af:inputText". With that Data i want to populate the af:selectOneChoice Component.

What needs to be considered is, that postcode is not the primary Key so methods like findByKey wont work.

Can i make this using EntityObjects/ViewObjects or do i need to manually open a Database Connection, create a Statement and execute the Query that way?

What is the ADF way to do it?