Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @Entity
- @Table(name = "full_address")
- public class FullAddress {
- @Id
- @Column(name = "guid")
- private String id;
- @Column(name = "address")
- private String address;
- //getters and setters omitted
- }
- CREATE TABLE address_table (
- -- address fields,
- aoid VARCHAR(36),
- CONSTRAINT address_pk PRIMARY KEY (aoid)
- );
- CREATE MATERIALIZED VIEW full_address AS
- SELECT buildFullAddressById(addrobj.aoid) AS address, addrobj.aoid AS guid FROM address_table AS addrobj;
- -- buildFullAddressById is an sql function which is not important here
- final List<String> tableTypesList = new ArrayList<>();
- tableTypesList.add( "TABLE" );
- tableTypesList.add( "VIEW" );
- if ( extraPhysicalTableTypes != null ) {
- Collections.addAll( tableTypesList, extraPhysicalTableTypes );
- }
- if ( !"".equals( extraPhysycalTableTypesConfig.trim() ) ) {
- this.extraPhysicalTableTypes = StringHelper.splitTrimmingTokens(
- ",;",
- extraPhysycalTableTypesConfig,
- false
- );
- }
- final String extraPhysycalTableTypesConfig = configService.getSetting(
- AvailableSettings.EXTRA_PHYSICAL_TABLE_TYPES,
- StandardConverters.STRING,
- ""
- );
- /**
- * Identifies a comma-separate list of values to specify extra table types,
- * other than the default "TABLE" value, to recognize as defining a physical table
- * by schema update, creation and validation.
- *
- * @since 5.0
- */
- String EXTRA_PHYSICAL_TABLE_TYPES = "hibernate.hbm2dll.extra_physical_table_types";
- <?xml version="1.0" encoding="UTF-8"?>
- <persistence xmlns="http://xmlns.jcp.org/xml/ns/persistence"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd"
- version="2.1">
- <persistence-unit name="project-pu">
- <jta-data-source>java:jboss/datasources/project-pu</jta-data-source>
- <properties>
- <property name="hibernate.dialect" value="org.hibernate.spatial.dialect.postgis.PostgisPG95Dialect"/>
- <property name="hibernate.hbm2ddl.auto" value="validate"/>
- <property name="hibernate.hbm2dll.extra_physical_table_types" value="MATERIALIZED VIEW"/>
- <property name="hibernate.show_sql" value="false"/>
- <property name="hibernate.format_sql" value="false"/>
- <property name="hibernate.use_sql_comments" value="false"/>
- <property name="hibernate.connection.url" value="jdbc:postgresql://localhost:5432/mgt"/>
- <property name="hibernate.connection.driver_class" value="org.postgresql.Driver"/>
- </properties>
- </persistence-unit>
- </persistence>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement