Sunday, November 20, 2011

Primary key @OneToOne mapping in Hibernate (JPA)

My main objective is to save/insert as many POJO's as possible with the minimum # of calls to save method. That's why I'm relate them.

But there is a special relationship which it's not clearly documented on the official documentation, and that's why you'll see this entry here :)

.The problem is that I have 2 tables COURSE_ACCESS and COURSE_ACCESS_STATUS:
---------------
COURSE_ACCESS
---------------
*id
...
---------------

---------------------
COURSE_ACCESS_STATUS
---------------------
*course_access_id
...
---------------------

The relationship is 1:1. COURSE_ACCESS is the "parent" table, because that one has the SEQUENCE which generates the PK on "id" column.

Now what I want is when I save COURSE_ACCESS, COURSE_ACCESS_DATA should be saved too. Just like this
How I did it?



And that's it!!! Easy isn't it?

Wednesday, November 9, 2011

Building from source BPM Console (for JBPM4)

For some personal reasons I wanted to customize the JBPM Console, so the only way to do it is by building from source code.
The first thing I had to do is get the sources and compile them using Maven :)

If by any chance you're having a hard time with this error (like me)
[ERROR] Failed to execute goal on project gwt-console: Could not resolve dependencies for project org.jboss.bpm:gwt-console:war:2.2.3-Final: The following artifacts could not be resolved: org.timepedia.chronoscope:chronoscope:jar:2.0_jboss-SNAPSHOT, org.timepedia.chronoscope:chronoscope-api:jar:2.0_jboss-SNAPSHOT: Failure to find org.timepedia.chronoscope:chronoscope:jar:2.0_jboss-SNAPSHOT in https://repository.jboss.org/nexus/content/groups/public/ was cached in the local repository, resolution will not be reattempted until the update interval of jboss-public-repository-group has elapsed or updates are forced -> [Help 1]

Just do as I did. Go to Maven Hub and search for your missing jar, on my case I found it on Thirdparty-uploads repository (from JBoss);

Unfortunately, the version I was looking for (according to the previous error) was chronoscope:jar:2.0_jboss-SNAPSHOT and I found 2.0_jboss, I guess you know what to do now, don't you?

Just cheat Maven by installing on your local repository version "2.0_jboss" as "2.0_jboss-SNAPSHOT"

Voila!!!

As result you should get these 4 artifacts:
  • Console UI: gwt-console.war
  • Console Server: gwt-console-server.war
  • Domain model: gwt-console-rpc.jar
  • Integration Layer: gwt-console-server-integration.jar

Also, don't forget to include the bpaf-explorer jars. To avoid this:
14:52:32,728 [main] ERROR [ContainerBase] StandardWrapper.Throwable
com.google.inject.ProvisionException: Guice provision errors:

1) Error injecting constructor, java.lang.NoClassDefFoundError: org/jboss/bpm/monitor/model/metric/Timespan
  at org.jboss.errai.bus.server.service.ErraiServiceImpl.(ErraiServiceImpl.java:50)
  while locating org.jboss.errai.bus.server.service.ErraiServiceImpl
  while locating org.jboss.errai.bus.server.service.ErraiService

1 error
 at com.google.inject.InjectorImpl$4.get(InjectorImpl.java:767)
 at com.google.inject.InjectorImpl.getInstance(InjectorImpl.java:793)
 at org.jboss.errai.bus.server.servlet.AbstractErraiServlet.buildService(AbstractErraiServlet.java:117)
 at org.jboss.errai.bus.server.servlet.AbstractErraiServlet.init(AbstractErraiServlet.java:88)
 at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1161)