I Use Bing to Search, Google to Search Hard

Java JPA Just Sucks

6. March 2012 14:22 by Scott in Java, ESRI  //  Tags: ,   //   Comments (0)

Now hear me out, before you go commenting like crazy or I stir a hornets nest saying something bad about Java.

We have this project at work that has consumed a year and a half of development time.  Some developer in the very beginning decided to use Java JPA and Java webservices as the server side environment.  So we went with it.  After a while, we ran into Java JPA.  For those .Net folks out there, its Java’s attempt at LINQ or the Entity framework.  While its not bad, I seem to run across countless more problems with it than I ever would have with LINQ or Entity.

It generates tables poorly, it has problems with foreign keys and it doesn’t error out properly with good error codes or problems.  Overall, it is just a poor attempt.  Sort of reminds me when I started developing in highschool.  Tons of concepts, bad design and crappy documentation.

I attempted to convince my colleagues to move over to .Net before it was too late, but sadly they thought we were already too far in. 

If you would like some proof, well let me just show you.  I received this error just now.

JPA table “sequence” does not exist.

What sort of error is that?  Where does that come from and how would that even help me towards a solid solution?  So I google it and find one thing on stackoverflow.

Sadly, the link http://stackoverflow.com/questions/8761448/jpa-table-sequence-does-not-exist doesn’t help much either.

At least in .Net they will both tell you the problem and suggest a fix in the comments of the error.  Yes, thats right, they will suggest a fix.  You should all write your frameworks that way.  If you think an error is possible, help that poor coder along and give them solutions.  JPA reminds me a lot of ESRI code.

Thats my Rant.

Draw a Circle Graphic with ESRI Android SDK

14. November 2011 12:56 by Scott in Development, ESRI  //  Tags: , , ,   //   Comments (3)

I wrote this code a while back.  The requirement was to have a user draw a circle with the ESRI Android SDK.  Well, their Android SDK doesn't currently support drawing circles.  It draws all other types of polygons except for the circle.  So what does a Software Engineer do, we come up with our own implementation.

So for the world to see, here it is:

First we capture the OnMotionEvent and the comments are in line.

Hope this helps someone.

    public boolean onDragPointerMove(MotionEvent from, MotionEvent to) {

        if (tempCircleGraphic != null)

        // creates a new polygon to be drawn.
        _circleTemp = new Polygon();

        Point point = _map.toMapPoint(to.getX(), to.getY());

        // If the starting point is null, create a polyline and start a
        // path.
        if (_startPoint == null) {
            _startPoint = _map.toMapPoint(from.getX(), from.getY());
            // creates a polyline so we can measure the radius of the
            // person
            // drawing the circle.
            _polylineTemp = new Polyline();
            // starts the poly line
            _polylineTemp.startPath(_startPoint.getX(), _startPoint.getY());
        // continues the draw of the poly line
        _polylineTemp.lineTo((float) point.getX(), (float) point.getY());

        // calculates the circle when getting ready to be drawn.
        int pointsAroundCircle = 50; // N
        double radius = _polylineTemp.calculateLength2D(); // radius
        for (int i = 0; i < pointsAroundCircle; i++) {
            double fi = 2 * Math.PI * i / pointsAroundCircle;
            double x = radius * Math.sin(fi + Math.PI) + _startPoint.getX();
            double y = radius * Math.cos(fi + Math.PI) + _startPoint.getY();
            if (i == 0) // starts the drawing of the circle. if
                        // beginning
                        // the for loop
                _circleTemp.startPath(x, y);
            else if (i == pointsAroundCircle - 1) // ends the circle
                                                    // when at
                                                    // the end of the
                // for loop.
                // continues drawing the cirlce while it iterates
                _circleTemp.lineTo(x, y);
        // creates a new graphic and sets the geometry to a polygon.
        Graphic graphic = new Graphic();

        int drawColor = getDrawColor();
        int transparentColor = Color.argb(POLYGON_ALPHA, Color.red(drawColor),
                Color.green(drawColor), Color.blue(drawColor));
        SimpleFillSymbol fillSymbol = new SimpleFillSymbol(transparentColor);
        tempCircleGraphic = graphic;
        // add the updated graphic to graphics layer

        // Refresh the graphics layer
        return true;


Objects in this class cannot be updated outside an edit session ESRI

15. February 2011 13:33 by Scott in   //  Tags: , , ,   //   Comments (0)

I received this error while working on some ArcObjects Code.

Objects in this class cannot be updated outside an edit session.

It had to do with the relationships that I established inside the File Geodatabase I was saving to.

So I had to add a few lines and open up an EDIT SESSION on the workspace.  I guess if you don’t have any relationships, you don’t need an edit session, but when you start using relationships you have to start opening up an edit session.

So here is my code.  You will notice the 3 lines that open the IWorkspaceEdit and the last two lines that stop editing.

//First thing is to create a generic fGDB workspace factory class
IWorkspaceFactory workspaceFactory = new FileGDBWorkspaceFactoryClass();
//Create a workspace and point it to the fGDB file
IWorkspace workspace = workspaceFactory.OpenFromFile(DATABASE_PATH_WITH_ATTACHMENTS, 0) as IWorkspace;

IWorkspaceEdit edit = (IWorkspaceEdit)workspace;

//Add some EDIT code here to the DB...

//Remove references to the fGDB
workspaceFactory = null;
workspace = null;
datasets = null;