In JEE the EntityManager or EntityManagerFactory can
Group items matching
in title, tags, annotations or url
6More
Java Persistence/Runtime - Wikibooks, open books for an open world - 0 views
9More
java - what is difference between EntityManager.find() and EntityManger.getReference()?... - 0 views
- ...6 more annotations...
-
is allowed to return a proxy instread of an initialized instance, if the entity has not been loaded in the EntityManager before
13More
Shiro User - Shiro in CDI/JPA2/JSF2 project - 1 views
- ...10 more annotations...
-
Instead of configuring the ShiroFilter in my web.xml I had the IniShiroFilter configured. The IniShiroFilter creates a new SecurityManager from the ini file. This new SecurityManager didn't know about the realm I've added in my EnvironmentLoader, so it didn't have any realms.
-
I replaced it with the ShiroFilter in my web.xml and all seems to be working now with my CdiEnvironmentLoaderListener.
7More
shared by kuni katsuya on 29 Aug 12
- No Cached
How to get EntityManager in a Apache Shiro Realm | OpenShift by Red Hat - 0 views
openshift.redhat.com/...anager-in-a-apache-shiro-realm
ApacheShiro EntityManager Realm PersistenceContext

-
managed-bean from CDI BeanManager and then @PersistenceContext give me a EntityManager in this managed-bean
- ...4 more annotations...
13More
Java Persistence/Transactions - Wikibooks, open books for an open world - 0 views
-
implicitly defined through SessionBean usage/methods. In a SessionBean normally each SessionBean method invocation defines a JTA transaction.
- ...10 more annotations...
-
In JEE managed mode, such as an EntityManager injected into a SessionBean, the EntityManager reference, represents a new persistence context for each transaction. This means objects read in one transaction become detached after the end of the transaction, and should no longer be used, or need to be merged into the next transaction. In managed mode, you never create or close an EntityManager.
3More
Lean service architectures with Java EE 6 - JavaWorld - 0 views
-
DAOs aren't dead, but they cannot be considered as a general best practice any more. They should be created in a bottom-up, rather than a top-down, fashion. If you discover data-access code duplication in your service layer, just factor it out to a dedicated DAO and reuse it. Otherwise it is just fine to delegate to an EntityManager from a service. The enforcement of an empty DAO layer is even more harmful, because it requires you to write dumb code for even simple use cases. The more code is produced, the more time you must spend to write tests and to maintain it.
-
With JDK 1.5 and the advent of generics, it is possible to build and deploy a generic, convenient, and typesafe DAO once and reuse it from variety of services
-
DAOs aren't dead, but they cannot be considered as a general best practice any more. They should be created in a bottom-up, rather than a top-down, fashion. If you discover data-access code duplication in your service layer, just factor it out to a dedicated DAO and reuse it. Otherwise it is just fine to delegate to an EntityManager from a service. The enforcement of an empty DAO layer is even more harmful, because it requires you to write dumb code for even simple use cases. The more code is produced, the more time you must spend to write tests and to maintain it.
5More
JPA implementation patterns: Retrieving entities | Xebia Blog - 0 views
- ...2 more annotations...
-
Keeping the query and the code that sets these parameters together makes them both easier to understand
12More
shared by kuni katsuya on 07 Oct 12
- No Cached
Why you should never use getSingleResult() in JPA | Sysout.be - 0 views
sysout.be/...ver-use-getsingleresult-in-jpa
database JPA EntityManager.getSingleResult() EntityManager.getResultList()

- ...8 more annotations...
-
We never know for sure what we can expect from our database, so throwing an unchecked exception seems the wrong choice for this use-case
-
thinking defensively, in a pathological scenario, the data and/or schema of the database could be corrupt eg. using a named query that should return a single entity based on a unique constraint of a table: - what if the unique constraint was implemented incorrectly in the ddl? (too relaxed or too strict) - what if the data became inconsistent as a result of some external process? => should always code defensively, especially at integration points to anything external to the jvm
-
7More
The JPA 2 Enhancements Every Java Developer Should Know - Developer.com - 0 views
-
JPA 2 also introduced a second layer of cache, which is shared across various persistence contexts and can be accessed using the EntityManagerFactory
- ...4 more annotations...
35More
Pro JPA 2: Mastering the Java™ Persistence API > Advanced Topics > SQL Querie... - 0 views
- ...32 more annotations...
-
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.
-
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.
-
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.
-
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.
-
createNamedQuery() can return a TypedQuery whereas the createNativeQuery() method returns an untyped Query
15More
15 Tips on JPA Rich Domain Modelling - Thinking In Objects - Not Mappings [For Greenfie... - 0 views
-
Try to identify concepts and abstractions from the target domain. Use them as candidates for entities.
- ...10 more annotations...
-
-
Let the tool (JPA-provider) generate the DDL