Distinct list of embedded entities

Posted by Mike Haller on Saturday, August 9. 2008 at 06:39 in Java
With the Java Persistence API (JPA), you can create embeddable entities, which will be persisted within the table of the container object instead of a relation. Suppose you've got a Customer class and an embeddable Address class like this:

package example;
@Entity
public class Customer {
 private String name;
 @Embedded
 private Address address;
}

package example;
@Embeddable
public class Address {
 private String zip;
 private String city;
}


You will eventually end up with the following table:
CUSTOMER
NAME, ZIP, CITY


My first naive approach querying the embeddable entity to get a list of all cities did not work:
SELECT DISTINCT c.city FROM Customer c


The solution is not really straight forward and intuitive, but still rather easy.
You need to add a constructor with all the fields and use the NEW operator of JPQL:
SELECT DISTINCT NEW example.Address(c.zip,c.city) FROM Customer c


Open Flash Chart

Posted by Mike Haller on Friday, August 8. 2008 at 06:12 in Java

For a private project i'm working now and then, i came across a nice library called Open Flash Chart (OFC). It let's me create nice looking charts with low effort. After hacking Maven and hooking into the event dispatcher for goals, the tool is persisting the data collected from the local Maven builds of developers. A web application aggregates the data and uses OFC to display graphs. It's planned to provide more data graphs, such as count of tests, successes, failures and skipped tests, coverage data etc.



This is a graph showing the durations of the surefire:test goal on a sample project. Hovering over the dots will show a tooltip with additional information.

Version 1 of OFC is using a proprietary data format which looks like this:
&title=com.smartwerkz.commons&
&tool_tip=Build+#x_label#+took+&val;ms&
&x_label_style=10,0x80a033,2&
&y_legend=Goal+surefire:test,10,#736AFF&
&y_max=4207&
&line_hollow=2,Build+Time+[ms],10,4&
&values=3825,1222,948,928,926,1002&


Upcoming Version 2 of OFC is going to use JSON as the data format, which will hopefully be more clearer to use and easier to generate.


About

My name is Mike Haller and I'm a software developer and architect at Bosch Software Innovations in Germany. I love programming, playing games and reading books. I like good food, making photos and learning and mentoring about the craftsmanship of commercial software development. Stack Overflow profile for mhaller

Quicksearch

Archives