2 * Copyright © 2017-2018 AT&T Intellectual Property.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 package org.onap.ccsdk.cds.controllerblueprints;
19 import org.springframework.boot.autoconfigure.domain.EntityScan;
20 import org.springframework.context.annotation.Bean;
21 import org.springframework.context.annotation.Configuration;
22 import org.springframework.data.jpa.repository.config.EnableJpaAuditing;
23 import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
24 import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean;
25 import org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter;
26 import org.springframework.transaction.annotation.EnableTransactionManagement;
28 import javax.sql.DataSource;
31 * DatabaseConfig.java Purpose: Provide Configuration Generator DatabaseConfig Information
33 * @author Brinda Santh
37 @EntityScan("org.onap.ccsdk.cds.controllerblueprints.service.domain")
38 @EnableTransactionManagement
39 @EnableJpaRepositories("org.onap.ccsdk.cds.controllerblueprints.service.repository")
41 public class DatabaseConfig {
43 * This is a entityManagerFactory method
46 * @return LocalContainerEntityManagerFactoryBean
50 public LocalContainerEntityManagerFactoryBean entityManagerFactory(DataSource dataSource) {
51 HibernateJpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter();
52 vendorAdapter.setGenerateDdl(true);
53 vendorAdapter.setShowSql(false);
54 LocalContainerEntityManagerFactoryBean factory = new LocalContainerEntityManagerFactoryBean();
55 factory.setJpaVendorAdapter(vendorAdapter);
56 factory.setPackagesToScan("org.onap.ccsdk.cds.controllerblueprints.service.domain");
57 factory.setDataSource(dataSource);