Skip to main content

Home/ SoftwareEngineering/ Group items tagged JOINED

Rss Feed Group items tagged

kuni katsuya

Java Persistence/Inheritance - Wikibooks, open books for an open world - 0 views

  • Inheritance
  • hardest part of persisting inheritance is choosing how to represent the inheritance in the database
  • There are three inheritance strategies defined from the InheritanceType enum,
  • ...101 more annotations...
  • SINGLE_TABLE
  • TABLE_PER_CLASS
  • JOINED
  • Single table inheritance is the default
  • @MappedSuperclass
  • @Inheritance
  • mapped superclass is
  • not a persistent class
  • but allow common mappings to be define for its subclasses
  • Single Table Inheritance
    • kuni katsuya
       
      implemented as a sparse table. ie. all attributes from all entities end up as columns in the 'super' table
  • single table is used to store all of the instances of the entire inheritance hierarchy
  • table will have a column for
  • every attribute
  • every class
  • in the hierarchy
  • discriminator column
  • is used to determine which class the particular row belongs to
  • abstract
  • Project
  • extends Project
  • extends Project
  • @DiscriminatorValue("S")
  • @DiscriminatorValue("L")
  • @DiscriminatorColumn(name="PROJ_TYPE")
  • @Inheritance
  • @Table(name="PROJECT")
  • single table inheritance
  • Joined, Multiple Table Inheritance
  • mirrors the object model in the data model
  • table is defined for each class in the inheritance hierarchy to store only the local attributes of that class
  • Each table in the hierarchy must also store the object's id (primary key), which is
  • only defined in the root class
  • share the same id attribute
  • joined inheritance
  • @Inheritance(strategy=
  • InheritanceType.JOINED
  • @DiscriminatorColumn(name="PROJ_TYPE")
  • @Table(name="PROJECT")
  • abstract
  • Project
  • @DiscriminatorValue("L")
  • @Table(name=
  • "LARGEPROJECT"
  • LargeProject
  • Project
  • @DiscriminatorValue("S")
  • @Table(name=
  • "SMALLPROJECT"
  • SmallProject
  • Project
  • Table Per Class Inheritance
  • Advanced
  • table is defined for
  • each concrete class
  • in the inheritance hierarchy to store
  • all the attributes
  • of that class and
  • all of its superclasses
  • table per class inheritance
  • @Inheritance(strategy=
  • InheritanceType.TABLE_PER_CLASS
  • abstract
  • Project
  • @Table(name="LARGEPROJECT")
  • LargeProject
  • Project
  • @Table(name="SMALLPROJECT")
  • SmallProject
  • Project
  • Mapped Superclasses
  • similar to table per class inheritance, but does not allow querying, persisting, or relationships to the superclass
  • mapped superclass
  • @MappedSuperclass
  • abstract
  • Project
  • @Column(name="NAME")
  • @Table(name="LARGEPROJECT")
  • LargeProject
  • Project
  • @AttributeOverride
  • "PROJECT_NAME"
  • "name"
  • @Table("SMALLPROJECT")
  • SmallProject
  • Project
  • cannot have a relationship to a mapped superclass
  • Joined, Multiple Table Inheritance
  • oined, Multiple Table Inheritance
  • abstract
  • abstract c
  • extends Project
  • Mapped Superclasses
  • Mapped Superclasses
  • apped Superclasses
  • allows inheritance to be used in the object model, when it does not exist in the data model
  • @MappedSuperclass
  • MappedSuperclass
  • abstract
  • abstract
  • extends Project
  • extends Project
kuni katsuya

Hibernate - Many-to-Many example - join table + extra column (Annotation) - 0 views

  • Many-to-Many example – join table + extra column (Annotation)
  • For many to many relationship with
  • NO extra column in the join table
  • ...1 more annotation...
  • please refer to this @many-to-many tutorial
kuni katsuya

Java Persistence/Relationships - Wikibooks, open books for an open world - 0 views

  • Map Key Columns (JPA 2.0)
  • Nested Collections, Maps and Matrices
  • List of Lists
  • ...58 more annotations...
  • Map of Maps,
  • Map of Lists
  • JPA does not support nested collection relationships
  • One solution is to create an object that wraps the nested collection.
  • Map<String, List<Project>>
  • Example nested collection model (original)
  • Example nested collection model (modified)
  • Map<String, ProjectType>
  • @MapKey(name="type")
  • mappedBy="employee"
  • employee
  • type;
  • List<Project>
  • ProjectType
    • kuni katsuya
       
      ProjectType wraps the original map value type List>
  • Maps J
  • JPA allows a Map to be used for any collection mapping including, OneToMany, ManyToMany and ElementCollection
  • @MapKey annotation
  • used to define a map relationship
  • @MapKey(name="type")
  • Map<String, PhoneNumber>
  • type;
  • mappedBy="owner"
  • owner
  • Map Key Columns (JPA 2.0)
  • Map Key Columns (JPA 2.0)
  • JPA 2.0 allows for a Map where the key is not part of the target object to be persisted. The Map key can be any of the following:
  • A Basic value, stored in the target's table or join table.
  • An Embedded object, stored in the target's table or join table.
  • A foreign key to another Entity, stored in the target's table or join table.
  • if the value is a Basic but the key is an Entity a
  • ElementCollection
  • mapping is used.
  • if the key is a Basic but the value is an Entity a
  • OneToMany
  • mapping is still used
  • a three way join table, can be mapped using a
  • ManyToMany with a MapKeyJoinColumn for the third foreign key
  • @MapKeyJoinColumn
  • used to define a map relationship where the
  • key is an Entity value
  • can also be used with this for composite foreign keys
  • @MapKeyClass
  • can be used when the key is an Embeddable
  • if generics are not used
  • @MapKeyColumn
  • Map<String, Phone>
  • mappedBy="owner"
  • owner
  • @MapKeyJoinColumn
  • PHONE_TYPE_ID
  • PHONE_TYPE_ID
  • Map<PhoneType, Phone>
  • mappedBy="owner"
  • owner
  • @MapKeyClass(PhoneType.class)
  • @Embeddable
  • PhoneType
  • Map<PhoneType, Phone>
  •  
    "Map Key Columns (JPA 2.0)"
kuni katsuya

DataNucleus Access Platform - JPA Inheritance - 0 views

  • DataNucleus AccessPlatform 3.1 Documentation
  • JPA : Inheritance Strategies
  • JOINED
  • ...2 more annotations...
  • "JOINED" strategy
  • each entity in the inheritance hierarchy has its own table and that the table of each class only contains columns for that class
kuni katsuya

Chapter 5. Basic O/R Mapping - 0 views

  • 5.1.6.2. Joined subclass strategy
  • A discriminator column is not required for this mapping strategy
  •  
    "5.1.6.2. Joined subclass strategy"
kuni katsuya

[#ANN-140] Discriminator column not supported with JOINED strategy - Hibernate JIRA - 0 views

  • Hibernate does not need a discriminator
  • because Hibernate is better than these other inferior implementations
  • It is allowed for
  • ...2 more annotations...
  • inferior implementations
  • of the JOINED mapping strategy which require a discriminator
kuni katsuya

EclipseLink/Examples/JPA/Inheritance - Eclipsepedia - 0 views

  • Joined Table Inheritance
  • Annotations
  • @Inheritance(strategy=InheritanceType.JOINED) @DiscriminatorColumn(name="TYPE", discriminatorType=DiscriminatorType.STRING,length=20) @DiscriminatorValue("P")
  • ...5 more annotations...
  • @DiscriminatorValue("L")
  • Single Table Inheritance
  • Annotations
  • @Inheritance(strategy=InheritanceType.SINGLE_TABLE) @DiscriminatorColumn(name="TYPE", discriminatorType=DiscriminatorType.STRING,length=20) @DiscriminatorValue("P")
  • @DiscriminatorValue("L")
kuni katsuya

Lazy Loading Entities In Views Challenge--Reader's Question And Answer : Adam Bien's We... - 0 views

  • Lazy Loading Entities In Views
  • class User
  • Address
  • ...10 more annotations...
  • Friend
  • addresses are lazily loaded
  • detached mode already in the controller
  • eagerly loaded
  • It gets ugly pretty quickly
  • JXPath relations
  • Use Fetch Joins they are designed to prefetch lazy relations
  • Anti-Pattern
    • kuni katsuya
       
      DO NOT USE THE OPEN-SESSION-IN-VIEW *ANTI*-PATTERN
  • Use Stateful Session Beans
    • kuni katsuya
       
      do not penalty: death, or at least a public flogging
  • eager load the relations
    • kuni katsuya
       
      just don't hard-code this eager loading behavior by using jpa's FetchType.EAGER when annotating the entity beans if you do, you force all clients of said entity beans to *always* eager fetch everything, even if the client doesn't want/need the full depth/breadth of the object graph to eager load the relations when needed, try fetch joins (see item 5)
kuni katsuya

Java Persistence/ManyToMany - Wikibooks, open books for an open world - 0 views

  • Bi-directional Many to Many
  • object model can choose if it will be mapped in both directions
  • in which direction it will be mapped
  • ...9 more annotations...
  • one direction must be defined as the owner and the other must use the mappedBy attribute to define its mapping
  • you will end up getting duplicate rows
  • If the mappedBy is not used, then the persistence provider will assume there are two independent relationships
  • As with all bi-directional relationships it is your object model's and application's responsibility to maintain the relationship in both direction
  • Mapping a Join Table with Additional Columns
  • solution is to create a class that models the join table
  • requires a composite primary key
  • To make your life simpler, I would recommend adding a generated Id attribute to the association class
  • Another usage is if you have a Map relationship between two objects, with a third unrelated object or data representing the Map key
    • kuni katsuya
       
      eg. map key = AuthorizationContext, map value = {Subject,Role}
kuni katsuya

Introduction to EclipseLink JPA (ELUG) - Eclipsepedia - 0 views

  •  
    "Mapping Inheritance"
kuni katsuya

Advanced entity association mappings (Hibernate) - 0 views

  • Ternary associations
  • Figure 7.12 A ternary association with a join table between three entities
  • Polymorphic associations
  • ...11 more annotations...
  • Polymorphic many-to-one associations
  • Polymorphic collections
  • Polymorphic associations to unions
  • Polymorphic table per concrete class
  • Fully polymorphic behavior is available, but there is no annotation support for any mappings.
  • Hibernate supports fully polymorphic behavior. It provides extra support for any association mappings to an inheritance hierarchy mapped with implicit polymorphism.
  • Hibernate Core
  • Table 7.1 Hibernate and JPA comparison chart
  • Java Persistence and EJB 3.0
  • Advanced entity association mappings (Hibernate)
  • Mapping maps
kuni katsuya

MySQL :: MySQL 5.1 Reference Manual :: 21.3.5.1 Driver/Datasource Class Names, URL Synt... - 0 views

  • The name of the class that implements java.sql.Driver in MySQL Connector/J is com.mysql.jdbc.Driver
  • JDBC URL Format The JDBC URL format for MySQL Connector/J is as follows, with items in square brackets ([, ]) being optional: jdbc:mysql://[host][,failoverhost...][:port]/[database] » [?propertyName1][=propertyValue1][&propertyName2][=propertyValue2]... If the host name is not specified, it defaults to 127.0.0.1. If the port is not specified, it defaults to 3306, the default port number for MySQL servers. jdbc:mysql://[host:port],[host:port].../[database] » [?propertyName1][=propertyValue1][&propertyName2][=propertyValue2]... Here is a sample connection URL: jdbc:mysql://localhost:3306/sakila?profileSQL=true
  • Initial Database for Connection If the database is not specified, the connection is made with no default database
  • ...2 more annotations...
  • fully specify table names using the database name (that is, SELECT dbname.tablename.colname FROM dbname.tablename...) in your SQL
  • work with multiple databases
    • kuni katsuya
       
      including cross database joins
1 - 12 of 12
Showing 20 items per page