Apache Derby 10.7.1.1 New Features
Finally, I have got a chance today to review new features of Apache Derby 10.7.1.1. Quite Promising!
Still I need to check effect of these new features from JPA Tooling perspective of Eclipse and other IDEs, as well as ORM code generation tools e.g. Hibernate, EclipseLink etc.
How to call a stored procedure and map resultset to entity with Derby and EclipseLink
Assume you have a stored procedure in your Derby/JavaDB instance with following signature:
APP.PICK_AIRLINES(AIRLINE CHAR(2))
This stored procedure returns a resultset that you want to map with your Entity class, say, Airline.
Firstly I should let you know that, till date, Apache Derby [my version is 10.5] does not support Named Parameter in Callable Statements.
So, we cannot simply use @NamedStoredProcedureQuery Annotation with @StoredProcedureParameter , rather we need to use StoredProcedureCall method. Read more…
Synching JPA Cache With Database in Multi-Application Environment Automatically — No Such Magic
1. We have a system in which 2 applications share the same database instance. Application 1 uses BC4J, while Application 2 uses Toplink/JPA. Because of the Toplink cache, all the changes persisted to DB done by Application 1 is not recognized by Application 2, unless we bounce the Application 2 server, or we wait for a long time. I guess this is a common problem that others encountered before. Please share your advice on this problem. Read more…
Hibernate as JPA provider for Entity Beans in EJB3
In recent past I was having a discussion with a person from a large MNC who wondered when I told that I have used Hibernate with EJB 3 entity beans , then asked me the significance of using such configuration. Well, I tried my level-best to make him understand that, but alas! the person who is not even aware of JPA spec and tied up with Java EE 1.4 with Weblogic and WebSphere, how can I make him understand!
Well, if you are aware of Java EE 6, EJB 3 Spec, JPA then and only then read ahead, else it will be wastage of your time.
Hibernate also support Entity beans and Java Persistence Provider(JPA) of EJB3.0+ specification. In fact many of the concepts of Entity beans has been taken from Hibernate. JBoss application server uses Hibernate as the default persistence provider for Entity beans and JPA. JPA has the notion of persistence unit which represents the configuration.
EntityManagerFactory of JPA corresponds to SessionFactory and EntityManager corresponds to Session.
Basically, EJB 3, JPA are spec and Hibernate is an implementation of JPA spec[ as TopLink, EclipseLink etc] so, if Entity Beans can use JPA then the underlying implementation could be be any JPA provider e.g. Hibernate,TopLink, EclipseLink etc.
Now, let me answer the second question: Significance of using Hibernate[JPA] with Entity Beans.
- You are free from any Vendor-LockIn, change your JPA implementation when-ever you need it.
- You are free to change your DataBase provider at any point of time with-out changing a single line of code[ except orm.xml or persistence.xml file]
- Even you can use the bean validation features of Entity beans with Hibernate validator.
- Use features like dynamic queries and named queries , which will be a really helpful if concurrency and application performance are of your concern.
- As well as most of the features of ORM tools are readily available.
Reference:
Understanding Java EE 6 and CDI
As Java EE 6 tutorial says:
The two most fundamental services provided by CDI are as follows:
- Contexts: The ability to bind the lifecycle and interactions of stateful components to well-defined but extensible lifecycle contexts
- Dependency injection: The ability to inject components into an application in a type-safe way, including the ability to choose at deployment time which implementation of a particular interface to inject
Let’s discuss with an example.
Suppose you are a frequent traveler need to travel from New Heaven to New York thrice a week and your nearest airport is Hartford. Every time you take a cab or drive to airport then take flight and fly to NY., i.e you are a dependent of transport service.
So, we can say that,in this case the type (Concrete Implementation) of the service depends on the source and destination and putting that concrete implementation in place at runtime (Injection) depending on scenario(i.e. Context) is Context & Dependency Injection.
JEE 6 uses annotation(Which had been introduced at Java 5) heavily to make developers’ life hassle free from writing lines of XML configuration.Five annotation constructs :
- @Inject,
- @Qualifier,
- @Produces,
- @Disposes and
- @Named
provide the basic building blocks for getting a thin loosely coupled layered modular structure to the view, hiding the boilerplate code one had to write before JEE 6.
I shall write more on this topic as I shall learn more.
FLV as Desktop Sharing Transport instead of JPEG
I was just going through the code for openmeetings and found that,
it’s using snaps of JPEG images for Desktop Sharing.
I have understood that, JPEG Format is not a good Idea for movie kind
of things where (N-1)th image is highly Co-related to Nth image with
Delta Changes, due to the nature of JPEG encoding which takes more
processing power.
So I had started to play with ADOBE’s “Screen Video” and
“ScreenVideo2″ format with FLV encapsulation and found dramatic
reduction in filesize.
Right now I have just successfully completed the FLV Encoding with
ScreenVideo, and I wish to use this as the base for Desktop Sharing.
What you say?
Thanks & Regards,
Puspendu Banerjee
Kolkata
India
Hibernate JPA GUID Generation
Copy and Paste the Blue colored Lines .
@Id
@Column(name = “Id”, unique = true, nullable = false, insertable = true, updatable = true, length = 45)
@GeneratedValue(generator=”db-guid”)
@GenericGenerator(name=”db-guid”, strategy = “guid”)
Java Class or Jar Files to EXE
Use JSMooth. It’s Free and GPL/LGPLed
http://jsmooth.sourceforge.net/