Skip to main content

Home/ SoftwareEngineering/ Group items tagged mapping

Rss Feed Group items tagged

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

Chapter 2. Mapping Entities - 0 views

  • Composite identifier
  • You can define a composite primary key through several syntaxes:
  • @EmbeddedId
  • ...66 more annotations...
  • map multiple properties as @Id properties
  • annotated the property as
  • map multiple properties as @Id properties and declare an external class to be the identifier type
  • declared on the entity via the @IdClass annotation
  • The identifier type must contain the same properties as the identifier properties of the entity: each property name must be the same, its type must be the same as well if the entity property is of a
  • basic type
  • last case is far from obvious
  • recommend you not to use it (for simplicity sake)
  • @EmbeddedId property
  • @EmbeddedId
  • @Embeddable
  • @EmbeddedId
  • @Embeddable
  • @Embeddable
  • @EmbeddedId
  • Multiple @Id properties
  • arguably more natural, approach
  • place @Id on multiple properties of my entity
  • only supported by Hibernate
  • does not require an extra embeddable component.
  • @IdClass
  • @IdClass on an entity points to the class (component) representing the identifier of the class
  • WarningThis approach is inherited from the EJB 2 days and we recommend against its use. But, after all it's your application and Hibernate supports it.
  • Mapping entity associations/relationships
  • One-to-one
  • three cases for one-to-one associations:
  • associated entities share the same primary keys values
  • foreign key is held by one of the entities (note that this FK column in the database should be constrained unique to simulate one-to-one multiplicity)
  • association table is used to store the link between the 2 entities (a unique constraint has to be defined on each fk to ensure the one to one multiplicity)
  • @PrimaryKeyJoinColumn
  • shared primary keys:
  • explicit foreign key column:
  • @JoinColumn(name="passport_fk")
  • foreign key column named passport_fk in the Customer table
  • may be bidirectional
  • owner is responsible for the association column(s) update
  • In a bidirectional relationship, one of the sides (and only one) has to be the owner
  • To declare a side as
  • not responsible for the relationship
  • the attribute
  • mappedBy
  • is used
  • mappedBy
  •  Indexed collections (List, Map)
  • Lists can be mapped in two different ways:
  • as ordered lists
  • as indexed lists
  • @OrderBy("number")
  • List<Order>
  • List<Order>
  • List<Order> 
  • To use one of the target entity property as a key of the map, use
  • @MapKey(name="myProperty")
  •  @MapKey(name"number")
  • Map<String,Order>
  • String number
    • kuni katsuya
       
      map key used in Customer.orders
  • @MapKeyJoinColumn/@MapKeyJoinColumns
  • if the map key type is another entity
  • @ManyToAny
  • 2.4.5.2. @Any
  • @Any annotation defines a polymorphic association to classes from multiple tables
  • this is most certainly not meant as the usual way of mapping (polymorphic) associations.
  • @ManyToAny allows polymorphic associations to classes from multiple tables
  • first column holds the type of the associated entity
  • remaining columns hold the identifier
  • not meant as the usual way of mapping (polymorphic) associations
kuni katsuya

BlazeDS Developer Guide - 0 views

  • Serializing between ActionScript and Java
  • java.util.Date (formatted for Coordinated Universal Time (UTC))
  • java.util.Date, java.util.Calendar, java.sql.Timestamp, java.sql.Time, java.sql.Date
  • ...19 more annotations...
  • Object (generic)
  • java.util.Map
  • Array (dense)
  • java.util.List
  • List becomes ArrayList SortedSet becomes TreeSet Set becomes HashSet Collection becomes ArrayList
  • Array (sparse) java.util.Map java.util.Map
  • java.util.Map If a Map interface is specified, creates a new java.util.HashMap for java.util.Map and a new java.util.TreeMap for java.util.SortedMap.
  • BlazeDS passes an instance of java.util.ArrayList to parameters typed with the java.util.List interface and any other interface that extends java.util.Collection. Then these types are
  • sent back to the client as mx.collections.ArrayCollection instances
  • If you require normal ActionScript Arrays sent back to the client, you must set the legacy-collection element to true in the serialization section of a channel-definition's properties; for more information, see Configuring AMF serialization on a channel.
  • legacy-collection Default value is false. When true, instances of
  • java.util.Collection
  • are returned as
  • ActionScript Arrays
  • legacy-map Default value is false. When true, java.util.Map instances are serialized as an ECMA Array or associative array instead of an anonymous Object.
  • A typical reason to use custom serialization is to avoid passing all of the properties of either the client-side or server-side representation of an object across the network tier.
  • standard serialization scheme, all public properties are passed back and forth between the client and the server.
  • Explicitly mapping ActionScript and Java objects
  • Private properties, constants, static properties, and read-only properties, and so on, are not serialized
kuni katsuya

JBoss Web Configuration Reference - The WEB subsystem - 1 views

  • mime-mapping That is the mapping of file extension to the Content-Type mime header. Most of the current file extensions are already hard coded in the web subsystem, you only need to add a mime-mapping is you want to overwrite the default mapping for a file extension or add a new file extension to the mapping. See below for more. There could be more than one mime-mapping per configuration.
  • mime-mapping The mime-mapping of configurationWeb SubSystem supports the following attributes: AttributeDescriptionname File extension to map. value Value to use.
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

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

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

Pro JPA 2: Mastering the Java™ Persistence API > Advanced Topics > SQL Querie... - 0 views

  • queries are also known as native queries
  • SQL Queries
  • reasons why a developer using JP QL might want to integrate SQL queries into their application
  • ...32 more annotations...
  • JPA 2.0, still contains only a subset of the features supported by many database vendors
  • features not supported in JP QL.
  • performance required by an application is to replace the JP QL query with a hand-optimized SQL version. This may be a simple restructuring of the query that the persistence provider was generating, or it may be a vendor-specific version that leverages query hints and features specific to a particular database.
  • recommend avoiding SQL initially if possible and then introducing it only when necessary
  • benefits of SQL query support is that it uses the same Query interface used for JP QL queries. With some small exceptions that will be described later, all the Query interface operations discussed in previous chapters apply equally to both JP QL and SQL queries.
  • keep application code consistent because it needs to concern itself only with the EntityManager and Query interfaces.
  • An unfortunate result of adding the TypedQuery interface in JPA 2.0 is that the createNativeQuery() method was already defined in JPA 1.0 to accept a SQL string and a result class and return an untyped Query interface
  • consequence is that when the createNativeQuery() method is called with a result class argument one might mistakenly think it will produce a TypedQuery, like createQuery() and createNamedQuery() do when a result class is passed in.
  • @NamedNativeQuery
  • resultClass=Employee.class
  • The fact that the named query was defined using SQL instead of JP QL is not important to the caller
  • SQL Result Set Mapping
  • JPA provides SQL result set mappings to handle these scenarios
  • A SQL result set mapping is defined using the @SqlResultSetMapping annotation. It may be placed on an entity class and consists of a name (unique within the persistence unit) and one or more entity and column mappings.
  • entities=@EntityResult(entityClass=Employee.class)
  • @SqlResultSetMapping
  • Multiple Result Mappings
  • A query may return more than one entity at a time
  • The SQL result set mapping to return both the Employee and Address entities out of this query
  • emp_id, name, salary, manager_id, dept_id
  • address_id, id, street, city, state, zip
  • order in which the entities are listed is not important
  • ntities={@EntityResult(entityClass=Employee.class), @EntityResult(entityClass=Address.class)}
  • expected result type and therefore received an instance of TypedQuery that is bound to the expected type. By qualifying the result type in this way, the getResultList() and getSingleResult() methods return the correct types without the need for casting.
  • Defining a Class for Use in a Constructor Expression
  • public EmpMenu(String employeeName, String departmentName)
  • List<EmpMenu>
  • NEW example.EmpMenu(" + "e.name, e.department.name)
  • EmpMenu.class
  • createNamedQuery() can return a TypedQuery whereas the createNativeQuery() method returns an untyped Query
  • List<Employee>
  • createNamedQuery("orgStructureReportingTo", Employee.class)
kuni katsuya

3 ways to serialize Java Enums | Vineet Manohar's blog - 0 views

  • Mapping enum to database column using JPA/Hibernate You can use any of the 3 approaches discussed above. Map the enum to an integer column. The persistence implementation should automatically convert enum to ordinal() and back for you. Map the enum to a String column. The persistence implementation should automatically convert the enum value to String value via the name() function. Map the enum using a business value. You should mark the enum field as @Transient, and create another String field which you can map to a String column in your database table. Here’s an example code snippet. view plaincopy to clipboardprint?@Entity  public class Product {   @Column   private String colorValue;     @Transient   public Color getColor() {    return Color.fromValue(colorValue);   }     public void setColor(Color color) {    this.colorValue = color.toValue();   }  }  
  • Approach 3: Using a user defined business value – Recommended approach! This approach involves assigning a an explicit user defined value to each enum constant and defining a toValue() and fromValue() methods on the enum to do the serialization and deserialization.
  • public enum Color {   RED("RED"), GREEN("GREEN"), BLUE("BLUE"), UNKNOWN("UNKNOWN");     private final String value;     Color(String value) {     this.value = value;   }     public static Color fromValue(String value) {     if (value != null) {       for (Color color : values()) {         if (color.value.equals(value)) {           return color;         }       }     }       // you may return a default value     return getDefault();     // or throw an exception     // throw new IllegalArgumentException("Invalid color: " + value);   }     public String toValue() {     return value;   }     public static Color getDefault() {     return UNKNOWN;   }  }  public enum Color { RED("RED"), GREEN("GREEN"), BLUE("BLUE"), UNKNOWN("UNKNOWN"); private final String value; Color(String value) { this.value = value; } public static Color fromValue(String value) { if (value != null) { for (Color color : values()) { if (color.value.equals(value)) { return color; } } } // you may return a default value return getDefault(); // or throw an exception // throw new IllegalArgumentException("Invalid color: " + value); } public String toValue() { return value; } public static Color getDefault() { return UNKNOWN; } } This approach is better than approach 1 and approach 2 above. It neither depends on the order in which the enum constants are declared nor on the constant names.
kuni katsuya

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

  •  
    "Mapping Inheritance"
kuni katsuya

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

  • Result Set Mapping
  • When a native SQL query returns objects, the SQL must ensure it returns the correct data to build the resultClass using the correct column names as specified in the mappings. If the SQL is more complex and returns different column names, or returns data for multiple objects then a @SqlResultSetMapping must be used.
  • @NamedNativeQuery
  • ...7 more annotations...
  • resultClass=Employee.class
  • class Employee
  • createNamedQuery("findAllEmployeesInCity")
  • List<Employee>
  • @NamedNativeQuery
  • resultSetMapping="employee-address"
  • @SqlResultSetMapping(name="employee-address", entities={ @EntityResult(entityClass=Employee.class), @EntityResult(entityClass=Address.class)} )
  •  
    Result Set Mapping
kuni katsuya

GraniteDS - deserialize ActionScript object to a Java Map object - Ross Henderson - 0 views

  • GraniteDS – deserialize ActionScript object to a Java Map object
  • key of type String and a value of type List
  • HOWEVER, the value has to be an ArrayCollection, not an Array.
  • ...2 more annotations...
  • Dictionary object is very similar to Java’s Map object.
  • Granite claims to implement the same serialization/deserialization matrix as BlazeDS (with two small exceptions).
kuni katsuya

Chapter 2. Mapping Entities - 0 views

  • 2.2.3. Mapping identifier properties
  • @Id annotation lets you define which property is the identifier of your entity
  • can be set by the application itself
  • ...1 more annotation...
  • or be generated by Hibernate (preferred)
kuni katsuya

Hibernate - 0 views

  • what-when-how In Depth Tutorials and Information
  • Understanding object/relational persistence (Hibernate)
  • Mapping persistent classes (Hibernate)
  • ...5 more annotations...
  • Mapping collections and entity associations (Hibernate)
  • Advanced entity association mappings (Hibernate)
  • Inheritance and custom types (Hibernate)
  • Domain models and metadata (Hibernate)
  • Transactions and concurrency (Hibernate)
kuni katsuya

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

  • Access Type
  • field
  • get method
  • ...21 more annotations...
  • FIELD
  • PROPERTY
  • Either all annotations must be on the fields, or all annotations on the get methods, but not both (unless the @AccessType annotation is used)
  • if placed on a get method, then the class is using PROPERTY access
  • For FIELD access the class field value will be accessed directly to store and load the value from the database
  • field can be private or any other access type
  • FIELD is normally safer, as it avoids any unwanted side-affect code that may occur in the application get/set methods
  • For PROPERTY access the class get and set methods will be used to store and load the value from the database
  • PROPERTY has the advantage of allowing the application to perform conversion of the database value when storing it in the object
  • be careful to not put any side-affects in the get/set methods that could interfere with persistence
  • Common Problems
  • Odd behavior
  • One common issue that can cause odd behavior is
  • using property access and putting side effects in your get or set methods
  • For this reason it is generally recommended to
  • use field access in mapping, i.e. putting your annotations on your variables not your get methods
  • causing duplicate inserts, missed updates, or a corrupt object model
  • if you are going to use property access, ensure your property methods are free of side effects
  • Access Type
  • Access Type
  • Access Type
  •  
    "Access Type"
kuni katsuya

Not able to set global mime-mapping | JBoss AS 7 | JBoss Community - 1 views

  • Not able to set global mime-mapping
  • mime-mapping is complex field and not resource. that is why it has its own operation handlers add-mime/remove-mime to handle its value. what are you trying to achive can be done by command:
  • /subsystem=web/configuration=container:add-mime(name=manifest,value="text/cache-manifest")
  • ...1 more annotation...
  • Just bit of a warning when using this, there was a bug in 7.1.1 when you added mime type that prevented server to start.so please use 7.1.2 or 7.2 nightly builds where this is fixed.
kuni katsuya

MySQL & Apache Derby as jdbcRealm for Apache Shiro | Nabil Hachicha - 0 views

  • http://localhost:8080/ShiroDemo/auth/secured.jsp
  • MySQL & Apache Derby as jdbcRealm for Apache Shiro
  • Step 1 creating a simple WebApp
  • ...36 more annotations...
  • Step 2 securing some content
  • create a database that will hold the list of the authorized users along with their password
  • Create a new directory “auth” and add a new JSP under it, let’s call it “BackOffice.jsp“
    • kuni katsuya
       
      create directory 'auth' under webapps directory
  • enable Shiro into our project by adding a ServletFilter into our Web.xml
  •  <filter-class>05            org.apache.shiro.web.servlet.IniShiroFilter06        </filter-class>
  • 10    <filter-mapping>11         <filter-name>ShiroFilter</filter-name>12         <url-pattern>/*</url-pattern>13    </filter-mapping>
  • classpath:shiro.ini
  • shiro-core
  • shiro-web
  • create shiro.ini under resource dir
  • 07ds.jdbcUrl=jdbc:derby://localhost:1527/shiro_schema08ds.username = APP09ds.password = APP
  • 15/auth/** = authcBasic16/** = anon
  • jdbcRealm.authenticationQuery
  • jdbcRealm=org.apache.shiro.realm.jdbc.JdbcRealm
  • setup the jdbc realm, this is where Shiro will find the authorized users
  • map the URLs to be protected, all the url under /auth should be authenticated with basic HTTP authentication
  • All the other URLs should be accessed without authentication
  • Add a new directory under src let’s call it production we will create a new shiro configuration file compatible with MySQL
    • kuni katsuya
       
      create src/production/resources/shiro.ini with contents below
  • 06ds.serverName = localhost07ds.user = ADM08ds.password = secret12309ds.databaseName = shiro_schema
  • jdbcRealm which use a MySQL driver
  • jdbcRealm.dataSource = $ds
  • jdbcRealm.dataSource=$ds
  • added the appropriate dependency to maven pom.xml
  • mysql-connector-java
  • environment.type
  • staging
  • 13                <jdbc.user>APP</jdbc.user>14                <jdbc.passwd>APP</jdbc.passwd>15                <jdbc.url>jdbc:derby://localhost:1527/shiro_schema</jdbc.url>16                <jdbc.driver>org.apache.derby.jdbc.ClientDriver</jdbc.driver>
  • src/main/resources
  • derbyclient
  • production
  • environment.type
  • 45                <jdbc.user>ADM</jdbc.user>46                <jdbc.passwd>secret123</jdbc.passwd>47                <jdbc.ds>com.mysql.jdbc.jdbc2.optional.MysqlDataSource</jdbc.ds>48                <jdbc.serverName>localhost</jdbc.serverName>49                <jdbc.databaseName>shiro_schema</jdbc.databaseName>
  • src/production/resources
  • To build and run for staging
  • To build for production
  • -Denvironment.type=prod
kuni katsuya

12 Tips On JPA Domain Modelling - With Existing Database - Thinking In Structs Not Obje... - 0 views

  • think in structs. Try to as frictionless as possible export/generate the JPA-entities from the existing database
  • Implement a very thin facade / transaction boundary
  • @Stateless Bean (EJB 3)
  • ...10 more annotations...
  • If the JPA entities still do not look right, try to apply some JPA tricks like mapping a JPA-entity to several tables, or even map JPA-entities to DB-views, to improve the situation
  • Rename the classes into some more meaningful. The attribute, class names are in general everything but not fluent
  • Junit. Purpose: JPA mapping verification
  • Thinking In Structs Not Objects
  • 12 Tips On JPA Domain Modelling
  • - With Existing Database -
    • kuni katsuya
       
      strategy when constrained by baggage of *legacy database* schema, NOT for a green fields project!
  • Execute the "Unit" tests after every change
  • even better get rid of them
  • domain objects are
  • semi-objectoriented
kuni katsuya

Chapter 4. Remoting and Serialization - 0 views

  • 4.3. Mapping Java and AS3 objects
  • data conversions are done during serialization/deserialization
  • Externalizers and AS3 Code Generation
  • ...21 more annotations...
  • Due to the limited capabilities of the ActionScript 3 reflection API than cannot access private fields, it is necessary to create an externalizable AS3 class (implementing flash.utils.IExternalizable and its corresponding externalizable Java class
  • writeExternal
  • In both classes you have to implement two methods
  • the Gas3 generator can automatically generate the writeExternal and readExternal methods.
  • With GraniteDS automated externalization and without any modification made to our bean, we may serialize all properties of the Person class, private or not
  • In order to externalize the Person.java entity bean, we must tell GraniteDS which classes we want to externalize with a
  • externalize all classes named com.myapp.entity.Person by using the org.granite.hibernate.HibernateExternalizer
  • you could use this declaration, but note that type in the example above is replaced by
  • instance-of:
  •             <include annotated-with="javax.persistence.Entity"/>             <include annotated-with="javax.persistence.MappedSuperclass"/>             <include annotated-with="javax.persistence.Embeddable"/>
  • : type
  • annotated-with
  • Instead of configuring externalizers with the above method, you may use the
  • feature:
  • precedence rules for these three configuration options:
  • <granite-config scan="true"/>
  • autoscan
  • GraniteDS will scan at startup all classes
  • found in the classloader of the GraniteConfig class, and discover all externalizers (classes that implements the GDS Externalizer interface)
  • DefaultExternalizer
  • this externalizer may be used with any POJO bean.
  •  
    4.3. Mapping Java and AS3 objects
1 - 20 of 42 Next › Last »
Showing 20 items per page