Apache Derby 10.7.1.1 New Features

January 8, 2011 Leave a comment

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.

Read more…

Categories: Persistence

How to call a stored procedure and map resultset to entity with Derby and EclipseLink

December 26, 2010 2 comments

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…

Categories: Java, Persistence

Synching JPA Cache With Database in Multi-Application Environment Automatically — No Such Magic

December 22, 2010 Leave a comment

Hibernate as JPA provider for Entity Beans in EJB3

September 20, 2010 Leave a comment

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:

  1. http://www.oracle.com/technetwork/articles/javaee/jpa-137156.html
  2. http://docs.jboss.org/hibernate/stable/annotations/reference/en/html/entity.html
Categories: Java Tags: , , ,

Understanding Java EE 6 and CDI

May 23, 2010 2 comments

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 :

  1. @Inject,
  2. @Qualifier,
  3. @Produces,
  4. @Disposes and
  5. @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. :)

Hibernate JPA GUID Generation

July 8, 2007 Leave a comment

 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”)

Categories: Java Tags: ,

Java Class or Jar Files to EXE

July 8, 2007 Leave a comment

Use JSMooth. It’s Free and GPL/LGPLed

http://jsmooth.sourceforge.net/

Categories: Java Tags: ,
Follow

Get every new post delivered to your Inbox.