Sat, 30 May 2009

10:02 PM - Apache Cayenne

 I've been working on converting just journal over to Apache Cayenne today.  I figured it would give me an opportunity to get better with it.  Cayenne has a nice modeling program, but their documentation is often lacking.

For example, suppose you're getting an error from your servlet container (Tomcat in my case) about a filter not loading.  With Cayenne, the "correct" way to use it is to load a filter mapped to /* that catches all the sessions and maps a DataContext to them.  You might find after pulling your hair out that there is a syntax error in your DomainNode.driver.xml file.  Even with logging cranked up in log4j, it will not tell you what's wrong with the filter.  However, if you initialize like a traditional app in a jsp page, you can see the error.  Invalid passwords are an example of what can cause this.

 

tags: java cayenne apache

()

Wed, 8 Jul 2009

10:33 PM - (no subject)

 Today was an interesting day at work.  I managed to get Cayenne working properly for a Project -> User mapping through some intermediate tables.  There were few tricks involved.  First, I had to modify the User class within Cayenne to explicitly have a mapping for the Primary key.  This allows you to do an Expression.fromString and refer to the primary key.  Second, I had to do a double mapping using the relationship name between the project and the mapping table then the mapping table to user table relationship.  The context had to be the name from the project end and from the mapping table end to the user table.  (left to right... )  

One problem I had early on was that we also have a user_id stored as the "owner" with a relationship in the project table.  That means there's a direct relationship and an indirect relationship between project and user.  

The idea here was to map all the projects that the User can access.  The mapping table contains a PK, user_id and project_id.  A user can potentially access many projects.  We knew the user id of the user logged in from the session (username would work too and require less work, but could not benefit from the database indexes).  

This sounds trivial, but there is almost no documentation on something like this with Cayenne.  Those apache developers need to get up some real examples of Cayenne apps.  

tags: java apache cayenne db mysql

()

Fri, 5 Feb 2010

7:50 PM - Cayenne 3.0RC2

I just read that Cayenne 3.0 RC2 is out.  Cayenne is an ORM.   I've been using it for almost a year now.  It's a very easy way to do data access in Java.  There are a few quirks.  Most people love Hibernate and don't consider alternatives.  Cayenne is very easy to work with.  It has a client gui to configure and setup your mappings or you can write an XML file by hand.  

 

location: Home

tags: java database cayenne orm apache

()

Mon, 27 Mar 2017