Skip to main content

Home/ SoftwareEngineering/ Group items tagged Hibernate

Rss Feed Group items tagged

kuni katsuya

JPA Reference Guide - JBoss AS 7.0 - Project Documentation Editor - 0 views

  • Persistence unit properties
  • Should be hibernate3-bundled if Hibernate 3 jars are in the application archive (adapterModule and adapterClass will automatically be set for hibernate3-bundled).
  • org.jboss.as.jpa.hibernate:3 (Hibernate 3 integration classes)
  • ...14 more annotations...
  • jboss.as.jpa.adapterModule
  • jboss.as.jpa.adapterClass
  • org.jboss.as.jpa.hibernate3.HibernatePersistenceProviderAdaptor
  • Working with other persistence providers
  • A project to build integration for persistence providers like EclipseLink, is here.
  • Troubleshooting
  • “org.jboss.as.jpa” logging can be enabled to get the following information: INFO - when persistence.xml has been parsed, starting of persistence unit service (per deployed persistence.xml), stopping of persistence unit service DEBUG - informs about entity managers being injected, creating/reusing transaction scoped entity manager for active transaction TRACE - shows how long each entity manager operation took in milliseconds, application searches for a persistence unit, parsing of persistence.xml
  • To enable TRACE, open the as/standalone/configuration/standalone.xml (or as/domain/configuration/domain.xml) file. Search for <subsystem xmlns="urn:jboss:domain:logging:1.0"> and add the org.jboss.as.jpa category
  • Packaging the Hibernate 3.5 or greater 3.x JPA persistence provider with your application
  • jboss.as.jpa.providerModule needs to be set to hibernate3-bundled.
  • <property name="jboss.as.jpa.providerModule" value="hibernate3-bundled" />
  • Sharing the Hibernate 3.5 or greater JPA persistence provider between multiple applications
  • Applications can share the same Hibernate3 (for Hibernate 3.5 or greater) persistence provider by manually creating an org.hibernate:3 module (in the AS/modules folder). Steps to create the Hibernate3 module:
  • <property name="jboss.as.jpa.providerModule" value="org.hibernate:3" />
kuni katsuya

How do I migrate my application from AS5 or AS6 to AS7 - JBoss AS 7.0 - Project Documen... - 0 views

  • Configure changes for applications that use Hibernate and JPA
  • Update your Hibernate 3.x application to use Hibernate 4
  • Changes for Hibernate 3.3 applications
  • ...16 more annotations...
  • Changes for Hibernate 3.5 applications
  • if your application uses Hibernate 3 classes that are not available in Hibernate 4, for example, some of the validator or search classes, you may see ClassNotFoundExceptions when you deploy your application. If you encounter this problem, you can try one of two approaches: You may be able to resolve the issue by copying the specific Hibernate 3 JARs containing those classes into the application "/lib" directory or by adding them to the classpath using some other method. In some cases this may result in ClassCastExceptions or other class loading issues due to the mixed use of the Hibernate versions, so you will need to use the second approach. You need to tell the server to use only the Hibernate 3 libraries and you will need to add exclusions for the Hibernate 4 libraries. Details on how to do this are described here: JPA Reference Guide.
  • In previous versions of the application server, the JCA data source configuration was defined in a file with a suffix of *-ds.xml. This file was then deployed in the server's deploy directory. The JDBC driver was copied to the server lib/ directory or packaged in the application's WEB-INF/lib/ directory. In AS7, this has all changed. You will no longer package the JDBC driver with the application or in the server/lib directory. The *-ds.xml file is now obsolete and the datasource configuration information is now defined in the standalone/configuration/standalone.xml or in the domain/configuration/domain.xml file. A JDBC 4-compliant driver can be installed as a deployment or as a core module. A driver that is JDBC 4-compliant contains a META-INF/services/java.sql.Driver file that specifies the driver class name. A driver that is not JDBC 4-compliant requires additional steps, as noted below.
  • DataSource Configuration
  • domain mode, the configuration file is the domain/configuration/domain.xml
  • standalone mode, you will configure the datasource in the standalone/configuration/standalone.xml
  • MySQL datasource element:
  •         <connection-url>jdbc:mysql://localhost:3306/YourApplicationURL</connection-url>        <driver-class> com.mysql.jdbc.Driver </driver-class>        <driver> mysql-connector-java-5.1.15.jar </driver>
  •        <security>            <user-name> USERID </user-name>            <password> PASSWORD</password>        </security>
  • example of the driver element for driver that is not JDBC 4-compliant. The driver-class must be specified since it there is no META-INF/services/java.sql.Driver file that specifies the driver class name.
  •  <driver-class>com.mysql.jdbc.Driver</driver-class>
  • JDBC driver can be installed into the container in one of two ways: either as a deployment or as a core module
  • Install the JDBC driver
  • Install the JDBC driver as a deployment
  • In AS7 standalone mode, you simply copy the JDBC 4-compliant JAR into the AS7_HOME/standalone/deployments directory
  • example of a MySQL JDBC driver installed as a deployment:     AS7_HOME/standalone/deployments/mysql-connector-java-5.1.15.jar
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

JPA Reference Guide - JBoss AS 7.1 - Project Documentation Editor - 0 views

  • Troubleshooting The org.jboss.as.jpa logging can be enabled to get the following information: INFO - when persistence.xml has been parsed, starting of persistence unit service (per deployed persistence.xml), stopping of persistence unit service DEBUG - informs about entity managers being injected, creating/reusing transaction scoped entity manager for active transaction TRACE - shows how long each entity manager operation took in milliseconds, application searches for a persistence unit, parsing of persistence.xml
  • Container-managed Extended Persistence context
  • extended persistence context can
  • ...20 more annotations...
  • span multiple transactions
  • and allows data modifications to be queued up (like a shopping cart),
  • without an active JTA transaction
  • EXTENDED
  • entity lifecycle
  • is managed by the underlying persistence provider.
  • New (transient):
  • an entity is new if it has just been instantiated using the new operator, and it is not associated with a persistence context. It has no persistent representation in the database and no identifier value has been assigned.
  • Managed (persistent):
  • a managed entity instance is an instance with a persistent identity that is currently associated with a persistence context.
  • Detached:
  • the entity instance is an instance with a persistent identity that is no longer associated with a persistence context, usually because the persistence context was closed or the instance was evicted from the context.
  • Removed:
  • a removed entity instance is an instance with a persistent identity, associated with a persistence context, but scheduled for removal from the database.
  • Replacing the current Hibernate 4.0.x jars with a newer version
  • update the current as7/modules/org/hibernate/main folder
  • Delete *.index files in as7/modules/org/hibernate/main and as7/modules/org/hibernate/envers/main folders
  • Remove the older jars and copy new Hibernate jars into as7/modules/org/hibernate/main + as7/modules/org/hibernate/envers/main.
  • Update the as7/modules/org/hibernate/main/module.xml
  • as7/modules/org/hibernate/envers/main/module.xml to name the jars that you copied in.
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

[#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

Inheritance and custom types (Hibernate) - 1 views

  • Choosing a strategy
  • You can apply all mapping strategies to abstract classes
  • and interfaces
  • ...8 more annotations...
  • Interfaces may have no state but may contain accessor method declarations, so they can be treated like abstract classes
  • Inheritance and custom types (Hibernate)
  • Mapping class inheritance
  • four different approaches to representing an inheritance hierarchy:
  • Table per concrete class with implicit polymorphism
  • Table per concrete class
  • Table per class hierarchy—
  • Table per subclass
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

JBoss AS 7 | Granite Data Services - 0 views

  • JBoss AS 7 with GDS 2.3
  • JBoss AS 7 is its deep integration with Hibernate 4 which makes very painful to deploy Hibernate 3.x applications
  • recommended to upgrade to H4
  • ...6 more annotations...
  • GraniteDS now fully supports Hibernate 4
  • use the granite-hibernate4.jar instead of granite-hibernate.jar
  • Flex 4.5 broke a few APIs and there were two main issues with Tide : The client libraries crashed when run in a mobile application The PagedQuery was unusable
  • These two issues are now fixed
  • granite-flex45.swc
  • Flex SDK 4.5 here
kuni katsuya

JPA/Hibernate Ternary Association « Fulvio Di Marco: just a personal code not... - 0 views

  • JPA/Hibernate Ternary Association
  •  
    "JPA/Hibernate Ternary Association"
kuni katsuya

Lazy Loading with Flex, BlazeDS and Hibernate | RIA Zone - 0 views

  • Lazy Loading with Flex, BlazeDS and Hibernate
  • By using dpHibernate and lazy loading, none of this extra work is required
  • proxies are sent initially for collections and complex objects, and fetched on-demand when requested by the client
  • ...2 more annotations...
  • Note that dpHibernate doesn't depend on Spring
  • entity classes must implement the org.dphibernate.core.IHibernateProxy interface, both on the Java and Actionscript classes
kuni katsuya

In Relation To...  Some tips on using Hibernate in JBoss AS 7.0.0.Final - 1 views

  • Some tips on using Hibernate in JBoss AS 7.0.0.Final
  • migrating Hibernate 3-based applications to JBoss AS7,
  • Container-deployed persistence units
  • ...6 more annotations...
  • Application-created persistence units
  • Native Hibernate applications
  • native (i.e. non-JPA)
  • JPA applications that create an EntityManagerFactory on their own, either using the PersistenceProvider SPI directly or through an intermediary mechanism such as Spring's LocalContainerEntityManagerFactoryBean
  • standard Java EE-applications may ignore the provider implementation and rely on the standard features provided by the container - JBoss AS7 supporting standard JPA 1.0 and 2.0
  • future versions of JBoss AS7 it will be possible to use alternative persistence provider implementations
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

Chapter 15. Data Management - 0 views

  • Data Management
  • Tide maintains a client-side cache of entity instances and ensures that every instance is unique in the Flex client context
  • Tide provides an integration between the Flex/LCDS concept of managed entities and the server persistence context (JPA or Hibernate).
  • ...10 more annotations...
  • All entities marked as [Managed] are considered as corresponding to Hibernate/JPA managed entities on the server
  • It is highly recommended to use JPA optimistic locking in a multi-tier environment (@Version annotation
  • In conclusion, the recommended approach to avoid any kind of subtle problems is to have a real uid property which will be persisted in the database
  • but is not a primary key for efficiency concerns
  • Here all loaded collections of the Person object will be uninitialized so uperson contains only the minimum of data to correctly merge your changes in the server persistence context
  • Tide uses the client data tracking (the same used for dirty checking, see below) to determine which parts of the graph need to be sent.
  • Dirty Checking and Conflict Handling
  • Data Validation
  • Tide integrates with Hibernate Validator 3.x and the Bean Validation API (JSR 303) implementations, and propagate the server validation errors to the client UI components
  • Data Paging
kuni katsuya

Chapter 3. Project Setup - 0 views

  • Using Maven archetypes
  • GraniteDS/Tide/CDI/JPA: graniteds-tide-cdi-jpa
  • GraniteDS/Tide/Seam 2/JPA/Hibernate: graniteds-tide-seam-jpa-hibernate
  • ...3 more annotations...
  • Maven 3 is highly recommended but Maven 2.2 should also work
  • CDI archetype defines an embedded GlassFish run configuration
  • mvn embedded-glassfish:run
kuni katsuya

dphibernate - Flex / BlazeDS Hibernate Adapter, with full lazy loading support - Google... - 0 views

  • dphibernate Flex / BlazeDS Hibernate Adapter, with full lazy loading support
1 - 20 of 50 Next › Last »
Showing 20 items per page