I have a class that needs to be mapped, I am using hibernate. But this class doesn't represent any specific table in the database, it contains fields from different tables. I have no idea how to do that, some help!? Thanks!
I don't know if this helps, but you can map an SQL view to an entity in your code. I'm not sure which databases support SQL views, I use Postgres.
So if you have the tables customer (customer_id, name) transaction (transaction_id, customer_id, date, description)
You can do:
Then you can map 'most_recent_transaction_view' as an entity. The differences are that you want to treat it as read-only, because of course updates to an SQL view are not supported. You also want to map the entity relationships as simple Entity properties instead of Entities.
e.g. from the example above, you want to map the customer_id as a String or Long, and not as a Customer object.
What are you doing? You are supposed to be reading this tiny ad!
the new thread boost feature brings a LOT of attention to your favorite threads