Retrieve data from multiple tables using Hibernate - spring

How can i fetch data from multiple tables in a database (mysql) using hibernate...
Can any one help me out in this regard... a sample example will be of great help, if possible.
Thanks.
Uday.

You could possibly use some custom sql to pull from the two tables and then map the output of that to the entity in question.
http://docs.jboss.org/hibernate/core/3.3/reference/en/html/querysql.html#querysql-creating

Related

How to fetch the data from database using spring boot without mapping

I have a database and in that database there are many tables of data. I want to fetch the data from any one of those tables by entering a query from the front-end application. I'm not doing any manipulation to the data, doing just retrieving the data from database.
Also, mapping the data requires writing so many entity or POJO classes, so I don't want to map the data to any object. How can I achieve this?
In this case, assuming the mapping of tables if not relevant, you don't need to use JPA/Hibernate at all.
You can use an old, battle tested jdbc template that can execute a query of your choice (that you'll pass from client), will serialize the response to JSONObject and return it as a response in your controller.
The client side will be responsible to rendering the result.
You might also query the database metadata to obtain the information about column names, types, etc. so that the client side will also get this information and will be able to show the results in a more convenient / "advanced" way.
Beware of security implications, though. Basically it means that the client will be able to delete all the records from the database by a simple query and you won't be able to avoid it :)

Oracle to Apache Cassandra data migration

I am working on an Apache Cassandra data migration. I have couple of tables which I need to move to the Cassandra column family with data - what is the best way to do this?
I have seen Apache Sqoop, will it help me? If yes, then what are the steps?
There is no silver bullet to migrate data from Oracle (or any RDBMS) to Cassandra. The way your data is modeled in Cassandra is fundamentally different from a relation database schema. Tools might help you to some degree, but you'll first have to create a new data model that will match the way you're going to read and write data into Cassandra. This article gives you a good start with Cassandra data modeling: http://www.datastax.com/dev/blog/basic-rules-of-cassandra-data-modeling

Compare data of table from two different Database

I have two separate database in two separate servers. Both these database have same table . I just wanted to compare similar tables wrt to the data contained.
Also to access one database from other database do I need to create a DBLink
Have you tried to find anything in Google? There are millions of posts for this topic.
Use this documentation to learn about dbms_comparison package

How to write JPQL query to get all the views and indexes from Oracle/postgreSQL DB

Hi every one,
I have a requirement to get all the views and indexes from Oracle/PostgreSQL DB
Here I have written one query like below to get all views
SELECT * FROM INFORMATION_SCHEMA.VIEWS where table_schema = 'public'
But that is postgreSQL dependent query right. Because in Oracle, information_schema was implemented differently so i thought to write jpql query but i dont know how to write.
Could anybody please help me out!
Thanks & regards,
Sridhar Kosna.
It's not possible. JPQL is only able to query mapped entities. Not database tables. You'll need to use SQL, and if you need to support multiple databases, have one DAO per database and use the appropriate DAO based on the used database.

working with LINQ to Entities against multiple sql server databases

I'm building a project combined of number of sites with common subject.
The sites rely on one central database that holds the common info for all of them.
In addition, each site has another database that holds its unique info (I will refer to it as unique-db in the next lines so I won't be misunderstood).
For example, the Languages table sits in the central db. That said, I suddenly noticed that I need to use the Languages table in one of my unique-db in order for the table to act as a FK so I don't have to create the same table again in the unique-db.
Do I have to create the same table again this time in the unique-db? Or is there a way to connect tables from separate databases?
In addition, we decided using linq2entity and soon we're gonna run some complex queries against the different databases. Will I have a problem with this matter?
How should I go on with that? Was it wise to split the data into a few databases?
I really appreciate all the help I can get!
One thing that might make your life easier is to create views of the central tables in each unique db. Linq to Entities will pick up views as if they were tables.

Resources