Hibernate map to views - mysql

Is it possible to make maps between beans and views in Hibernate. If there is please someone give show me an example. Thank you

Yes, it's possible. Hibernate doesn't care if the table is an actual table or a view. Just make sure to never update or create instances of such an entity, or mark it as non updatable.

Related

What is MySQL View for?

MySQL Documentation explains how to create a view. However it doesn't explain why should I make a MySQL View in the first place.
Thus, my question is, what is MySQL View? What is it for? At what circumstances should I make or not make one?
Quoting the documentation
The view definition is “frozen” at creation time and is not affected by subsequent changes to the definitions of the underlying tables.
I don't see how creating a view would be beneficial, so please, enlighten me.
View the data without storing the data into the object.
Restrict the view of a table i.e. can hide some of columns in the tables.
Join two or more tables and show it as one object to user.
Restrict the access of a table so that nobody can insert the rows into the table.
Where I work, we use the views as big painful querys that we need many times, we decided to create views for them instead of doing a manual query and when we need to access the information
SELECT * FROM view WHERE (anything)

Transact-SQL in BO XI?

I recently asked the following question and received a wonderful answer: SQL: Dynamic view with column names based on column values in source table
As someone not familiar at all with BusinessObjects, is there any way to perform this in InfoView? Would I have to edit the universe?
Sorry, I know this is a terrible question... but we're in a bind.
This might be possible via a derived table in the universe. A derived table allows you to write a custom query to provide objects in the universe.
I don't think so. It would require the dynamic creation and destruction of objects.

Correct foreigen key approach in jpa Or data saving basic approach

This question of mine is subjective
i am getting a list of objects from a third site.
now i want to save that data in database.
suppose the data is List. This response is to a query that i fired to that site .
now i want to save two things
1) query name
2) the response(List) (answer)
the myobject can have lot of answers corresponding to my query. now i want to save all these answers separately so that each answer can be fetched independently.
now i have this DB approach
one table for query and query id
second table which will consist of query id and query answer. (which will be foreigen key in first table
My question is am i following right approach?
initially i thought of saving the whole list in database but as per my knowledge we can not save list in database directly although in jpa implementation 2.0 we can save list in db (correct me if i am wrong)
please guide me with my current approach or of there is any better approach
i am using JPA 2.0 eclipselink.
Regards
Anil Sharma
What is your object model?
You can use OneToMany or ManyToMany to store a collection of Entity objects.
If you have a List or List you can store this using an ElementCollection.
But you may be better off creating an Answer or AnswerReference Entity.
See,
http://en.wikibooks.org/wiki/Java_Persistence/ElementCollection

How to make a nested query with an Entity that doesn't really exist (many-to-many)

I'm new with Doctrine2 so my question can be easy to answer (I hope so).
First of all, here the SQL query that I'd want :
SELECT *
FROM Document
WHERE id NOT IN (SELECT document_id FROM Documents_Folders)
Pretty simple isn't it ? The porblem is that my table 'Documents_Folders' is not an entity. In fact, it was create because I have a many-to-many relation between my entities 'Document' and 'Folder'.
I tried several queries, but none worked.
Thanks.
It really does look pretty simple, so it's not the problem with your SQL.
So if you want some help, tell us what is the error that you get?
BTW Your database shouldn't care what you use Documents_Folders for - it's just a table. (I don't know Doctrine2, but it's still regular database underneath, isn't it?)
Out of curiosity, What is your business case here.
Are you trying to get orphaned documents?
A Document can be part of Many Folders and a Folder can have many Documents?

LINQ-to-SQL classes from a select statement

I am a little new to linq-to-sql. I was just thinking suppose you wanted a subset of fields (in your db table) to actually be a data model in your application, what do you do? What I have thought of so far is to create a view from the actual db table and build linq-able classes using it.
Or is there a better way of doing this?
try these Walkthrough: Creating LINQ to SQL Classes (O/R Designer)
or these implemented in MVC Creating Model Classes with LINQ to SQL
One option is you can create Anonymous Types and use it.