Advertisement
Guest User

Untitled

a guest
Feb 5th, 2018
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.63 KB | None | 0 0
  1. @Entity
  2. @Table(name = "full_address")
  3. public class FullAddress {
  4.  
  5. @Id
  6. @Column(name = "guid")
  7. private String id;
  8.  
  9. @Column(name = "address")
  10. private String address;
  11.  
  12. //getters and setters omitted
  13. }
  14.  
  15. CREATE TABLE address_table (
  16. -- address fields,
  17. aoid VARCHAR(36),
  18. CONSTRAINT address_pk PRIMARY KEY (aoid)
  19. );
  20. CREATE MATERIALIZED VIEW full_address AS
  21. SELECT buildFullAddressById(addrobj.aoid) AS address, addrobj.aoid AS guid FROM address_table AS addrobj;
  22.  
  23. -- buildFullAddressById is an sql function which is not important here
  24.  
  25. final List<String> tableTypesList = new ArrayList<>();
  26. tableTypesList.add( "TABLE" );
  27. tableTypesList.add( "VIEW" );
  28.  
  29. if ( extraPhysicalTableTypes != null ) {
  30. Collections.addAll( tableTypesList, extraPhysicalTableTypes );
  31. }
  32.  
  33. if ( !"".equals( extraPhysycalTableTypesConfig.trim() ) ) {
  34. this.extraPhysicalTableTypes = StringHelper.splitTrimmingTokens(
  35. ",;",
  36. extraPhysycalTableTypesConfig,
  37. false
  38. );
  39. }
  40.  
  41. final String extraPhysycalTableTypesConfig = configService.getSetting(
  42. AvailableSettings.EXTRA_PHYSICAL_TABLE_TYPES,
  43. StandardConverters.STRING,
  44. ""
  45. );
  46.  
  47. /**
  48. * Identifies a comma-separate list of values to specify extra table types,
  49. * other than the default "TABLE" value, to recognize as defining a physical table
  50. * by schema update, creation and validation.
  51. *
  52. * @since 5.0
  53. */
  54. String EXTRA_PHYSICAL_TABLE_TYPES = "hibernate.hbm2dll.extra_physical_table_types";
  55.  
  56. <?xml version="1.0" encoding="UTF-8"?>
  57. <persistence xmlns="http://xmlns.jcp.org/xml/ns/persistence"
  58. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  59. xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd"
  60. version="2.1">
  61. <persistence-unit name="project-pu">
  62. <jta-data-source>java:jboss/datasources/project-pu</jta-data-source>
  63. <properties>
  64. <property name="hibernate.dialect" value="org.hibernate.spatial.dialect.postgis.PostgisPG95Dialect"/>
  65. <property name="hibernate.hbm2ddl.auto" value="validate"/>
  66. <property name="hibernate.hbm2dll.extra_physical_table_types" value="MATERIALIZED VIEW"/>
  67. <property name="hibernate.show_sql" value="false"/>
  68. <property name="hibernate.format_sql" value="false"/>
  69. <property name="hibernate.use_sql_comments" value="false"/>
  70. <property name="hibernate.connection.url" value="jdbc:postgresql://localhost:5432/mgt"/>
  71. <property name="hibernate.connection.driver_class" value="org.postgresql.Driver"/>
  72. </properties>
  73. </persistence-unit>
  74. </persistence>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement