Saturday, April 29, 2006

command-line tool for fetching with EOF

There are too many things to write about. If I think about all the things I want to say about WebObjects, the things I think people should know, my head threatens to explode.

Additionally, I do not know which of these things are important. Being inside the WebObjects group for so long has given me an odd perspective. There are things I care about that I think will seem arcane and inconsequential to others. It is hard to tell.

So, let us just start. There is a question which comes up occasionally, year after year, on the mailing lists. How does one create a tool for fetching with EOF? Let me just start with this. It is not complex, or even very interesting. But it is a start.


import com.webobjects.eoaccess.EOModelGroup;
import com.webobjects.eoaccess.EOUtilities;
import com.webobjects.eocontrol.EOEditingContext;

public class fetch {

public static void main(String[] arg) {
(new fetch()).fetch();

public void fetch() {
EOModelGroup group = EOModelGroup.defaultGroup();
try {
catch ( mue) { System.out.println(mue.getMessage()); }
EOEditingContext ec = new EOEditingContext();
NSArray rows = EOUtilities.objectsForEntityNamed(ec, "Movie");
System.out.println("retrieved rows # "+rows.count());


<project name="fetch" default="compile" basedir=".">

<target name="setup"><mkdir dir="classes/com/foo" /></target>

<property name="SLF" value="/System/Library/Frameworks" />
<property name="fRJ" value="framework/Resources/Java" />
<property name="Foundation" value="${SLF}/JavaFoundation.${fRJ}/javafoundation.jar" />
<property name="EOAccess" value="${SLF}/JavaEOAccess.${fRJ}/javaeoaccess.jar" />
<property name="EOControl" value="${SLF}/JavaEOControl.${fRJ}/javaeocontrol.jar" />
<property name="XML" value="${SLF}/JavaXML.${fRJ}/javaxml.jar" />
<property name="JDBC" value="${SLF}/JavaJDBCAdaptor.${fRJ}/javajdbcadaptor.jar" />

<path id="build.path">
<pathelement path="${Foundation}" />
<pathelement path="${EOAccess}" />
<pathelement path="${EOControl}" />
<path id="exec.path">
<path refid="build.path" />
<pathelement path="${XML}" />
<pathelement path="${JDBC}" />
<pathelement path="classes" />

<target name="compile" depends="setup">
<javac srcdir="." destdir="classes" classpathref="build.path">
<include name="" />

<target name="exec" depends="compile"><java classname="" fork="true" classpathref="exec.path" /></target>

Tuesday, April 18, 2006

The Perfect Beginning?

Staring at the blank screen. Thinking of how to come up with the perfect first post. O well. Never mind.

Camus comes to mind. A character in The Plague was trying to write the perfect novel. So, he needed the perfect first chapter. Really, he needed the perfect first sentence. He had spent years and years and filled up cabinets full of writing and had just the very first sentence. It was not yet finished.