connect to only one schema in hibernate - java

I am usning jBoss tools to generate POJO's from tables in my database but my database has many schemas so after configuration it took half of the day to show all the schemas.
Kindly let me know if there is any way to connect to the particular schema in database or any other property need to be defined in cfg file.
Thanks

You need to remove the schema information present in your POJO classes which you have generated through the reverse Hibernate mechanism of your JBOSS tools.Just create different hibernate configuration files(cfg) and supply the schema information.Hibernate will configure it accordingly.
So all you need to do is create a separate cfg file for each schema with your same POJO files included in both config files

Related

Multiple schema for SQL Server in Spring boot

My schema names are different for Test and Prod environments. How to access them from properties file? I want to read the schema from the properties file based on the environment. Tried the link suggested by adding in datasource config but it is not working. The database is SQL server.
you need to create a properties file for each profile (applications-test.properties and applications-prod.properties) and for each env you put your database configuration.
Make sure to use the right profile in your code.

Connection to Any one Data base in SpringBoot

Is there any way to load the respective hibernate config based on the property configured in a properties file.
I have an application to connect to Any database with the same schema through hibernate configs. Right now, I have created two hibernate configs One for DynamoDB another for all hibernate supported SQL's
I wanted to load only respective config by ignoring other config's.
i think we can specify like below
#Profile("prod")
#Configuration
Is it possible to create another property like profile.
There can be multiple profiles active at the same time in your application.
So you can have profiles for specific databases along with the profiles responsible for environment type.
Then, you can define your properties in files called application-dynamodb.properties and application-other.properties
Yes you can use #profile concept here.You can maintain multiple properties file with different configuration and activate that specific configurations for example by adding
spring.profiles.active=dev in application.properties, if application-dev.properties contains the required db configurations.But then you need to add #profile("dev") in configuration class while you are initializing/creating DB connection working with profile

Dynamically create schema in Spring boot application

I have a Spring boot application that uses JPA with Hibernate. It already connect to a primary data source for all transactions.
Now the task in hand is that I need to dynamically create Database Schema in a different database. For instance,
For project 1, create schema 1 in Database X
For project 2, create schema 2 in Database X
Later, these databases will be used by others externally. I am looking for the best way to get this done.
In case of defining multiple datasources in spring boot project, you have to declare associated beans in your configuration. With spring.jpa.hibernate.ddl-auto=create it will automatically create the schema in right database as answered here

Validate Weblogic Server Config.xml file with the correspondig schema

I have developed a tool to generate domain config files (config.xml and others) based on the set of velocity templates.
I now want to do a schema validation for this generated config.xml file.
Could you please suggest is there an api provided by weblogic, or what approach is better.
I tried with validating with the oracle provided schema (http://xmlns.oracle.com/weblogic/domain/1.0/domain.xsd), but i am getting error where one of the data type defined in the schema is not getting resolved.
Thanks.

Dynamic schema selection for Spring Data JPA repositories with schema coming from database

as the title says, I have an application (Spring Boot) which must execute some queries on specified objects on a SQL Server database. Such database having a single catalog and multiple schemas, which must be selected based on a previous query and some command line parameters.
I cannot seem to implement a strategy which involves Hibernate multi-tenancy, as most of the tutorials and answers on this site deal with schema names coming from a web request or an external parameter, while I need a database connection before creating the main multi-tenant EntityManager. So, I switched to a custom DataSource which tries to change the connection's default schema (using ALTER USER... WITH DEFAULT_SCHEMA = ...). But this also fails because the logged-in user does not have permission to alter his own default schema.
So I'm at a loss of what to do. Any suggestions?
Just create an EntityManager(Factory) per schema and put them in a map to choose from.
If you don't know the schemas before hand you can create EntityManager(Factory)s as soon as you learn about a schema.
that you can configure an EntityManagerFactory programatically.

Categories

Resources