Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Scout » Object from Database
Object from Database [message #1809562] Thu, 18 July 2019 09:07 Go to next message
Tim Meuser is currently offline Tim MeuserFriend
Messages: 16
Registered: February 2019
Junior Member
Hi,

the slq selects to import data to form data or table data works great. Now, I want to import data into a custom object. I created beans and tried to fill them with the BeanArrayHolder and the SQL selects in my service, but accessing the method returns me an error (images). Is this the right approach or should I do it differently? Thanks for your help in advance.

Regards,
Tim
Re: Object from Database [message #1809645 is a reply to message #1809562] Fri, 19 July 2019 09:17 Go to previous messageGo to next message
Patrick Baenziger is currently offline Patrick BaenzigerFriend
Messages: 96
Registered: September 2011
Member
Hi Tim

I think your issue is that your AoiBean does not have a no-arg constructor ( public AoiBean() ), which is needed to construct them on the fly.

Note: You could probably also improve the setter names - they probably should be named "setId" (not "setM_id").
That usually is a configuration issue of the IDE when you generate getters and setters and the IDE doesn't know the prefix you're using for the private field (m_ in your case).
Then you should (probably) be able to write "INTO :{aoi.id}" as well, instead of aoi.m_id
Re: Object from Database [message #1810033 is a reply to message #1809645] Mon, 29 July 2019 16:16 Go to previous messageGo to next message
Tim Meuser is currently offline Tim MeuserFriend
Messages: 16
Registered: February 2019
Junior Member
Thanks Patrick your answer helped me alot.
At the moment only one instance of the bean is created, how can I reload the bean everytime I call it?
IMapService service =  BEANS.get(IMapService.class);
setAois(service.loadAois());
Re: Object from Database [message #1810057 is a reply to message #1810033] Tue, 30 July 2019 07:37 Go to previous messageGo to next message
Patrick Baenziger is currently offline Patrick BaenzigerFriend
Messages: 96
Registered: September 2011
Member
Sorry, I don't quite understand your question. Could you explain your problem in a bit more detail, please?
(Do you only get one result row? What do you mean by "reload the bean everytime I call it"?)
Re: Object from Database [message #1810060 is a reply to message #1810057] Tue, 30 July 2019 07:52 Go to previous messageGo to next message
Tim Meuser is currently offline Tim MeuserFriend
Messages: 16
Registered: February 2019
Junior Member
When I call the first time
IMapService service =  BEANS.get(IMapService.class);
setAois(service.loadAois());

the bean is corretly loaded from my database (I can see the selects).
If I change something in the database and call the service again it will not update the bean (No sql selects).
Everytime I call the service, the bean should be loaded with the current data.
Re: Object from Database [message #1810061 is a reply to message #1810060] Tue, 30 July 2019 08:07 Go to previous messageGo to next message
Patrick Baenziger is currently offline Patrick BaenzigerFriend
Messages: 96
Registered: September 2011
Member
The code you had posted on the server side looks good (nothing cached or similar).
Note: The SQL service will return new objects for every query. It won't mutate result objects of previous queries.

Could you check the following (and provide as much detail what you expected vs. what happened):
- Server side: Do you see the changed values in the beans when you call the SQL Service after your database changes? (At the end of your loadAois() implementation)
- Client side: Does the service call return the beans with your expected changes?

What happens in your setAois() method? If you're depending on object reference equality (==) for detecting updates, that will not work (see the note above).

Re: Object from Database [message #1810170 is a reply to message #1810061] Fri, 02 August 2019 07:53 Go to previous message
Tim Meuser is currently offline Tim MeuserFriend
Messages: 16
Registered: February 2019
Junior Member
I had a problem in my setAois() method. It is now working correct.
Thanks for your help.
Previous Topic:Tablefield - Tablefield data not shown on a tab in a groupbox
Next Topic:Heatmap click event
Goto Forum:
  


Current Time: Sat Sep 21 03:59:00 GMT 2024

Powered by FUDForum. Page generated in 0.04749 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top