I've noticed that if I use the persistence API to create a database table the order of the table columns is not the same as in the persistence data-class. Is it possible to keep the field order in a data-class to a database table? asked 24.04.2014 at 10:29 Nikel Weis |
Another solution is to create your database in SQL first and then create your persistence data clases accordingly to the SQL-Database. So it is possible to apply a certain order. answered 06.06.2014 at 08:48 Nikel Weis You still need to use ORDER BY for certain queries because it is not guaranteed that your query result is in the very order of your database. So you need to manually ensure the order of your results, else you get a bug that is hard to pin down.
(06.06.2014 at 09:59)
Daniel Oechslin
I think there was a misunderstanding in my question. It is not the target to have the object in a certain order. The objective was that the columns within the database are in a certain order.
(06.06.2014 at 13:03)
Nikel Weis
|
The only solution I can think of is if you sort your data-class alphabetically and you add the ORDER BY attribute to your database query. answered 02.06.2014 at 12:47 Daniel Oechslin Thanks for your reply. That would be a possibility if the database should only be created via persistence - so +1 for that. But it is also possible to do it the other way around. :)
(06.06.2014 at 08:49)
Nikel Weis
|
Once you sign in you will be able to subscribe for any updates here
By RSS:Markdown Basics
Tags:
Asked: 24.04.2014 at 10:29
Seen: 2,493 times
Last updated: 06.06.2014 at 13:03