Search code examples
jpaormopenjpa

Database Crawler using JPA


We have a requirement for building a database crawler. The application parses the tnsnames, connects to each database and retrieves some information like version, accounts, etc. We are trying to use JPA across the other parts of the application and to persist this data into the application's database.

So far, I only see creating an EntityManagerFactory programmatically for every database. Is there any other options?

We are using Spring, are there any benefits that Spring brings to the table in this scenario?

Thanks


Solution

  • JPA is clearly not the right tool for this job. JPA allows creating functional entities mapping a well-know database schema. Your tool doesn't know anything about the schemas and tables it will find. There could be 0 tables or 5000, with completely unknow names.

    You need a much lower-level API to do what you want, like JDBC.

    You could use JPA to store the results of your crawlings in a single schema, though.