[class E] uses a non-entity [class E] as target entity in the relationship attribute [field
Busted in upon this error and didn’t find much for it online.
Its mainly caused because the Entity is not found in the persistance.xml document. You have to make sure its added.
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)
_graphicsLayer.removeGraphic(tempCircleGraphic);
// 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.
_circleTemp.closeAllPaths();
else
// 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();
graphic.setGeometry(_circleTemp);
int drawColor = getDrawColor();
int transparentColor = Color.argb(POLYGON_ALPHA, Color.red(drawColor),
Color.green(drawColor), Color.blue(drawColor));
SimpleFillSymbol fillSymbol = new SimpleFillSymbol(transparentColor);
graphic.setSymbol(fillSymbol);
tempCircleGraphic = graphic;
// add the updated graphic to graphics layer
_graphicsLayer.addGraphic(graphic);
// Refresh the graphics layer
_graphicsLayer.postInvalidate();
return true;
}
Running into another Error I figured I would blog about.
So im getting a Stub Error while trying to JUnit test a library I built with some Android code inside of it. The Error is as follows:
java.lang.RuntimeException: Stub!
at android.graphics.Color.rgb(Color.java:9)
at com.irad.conversion.gml.GmlConverter.GetAttributesFromGml(GmlConverter.java:446)
at com.irad.conversion.gml.GmlConverter.ConvertGmlPolygonToGraphic(GmlConverter.java:562)
at com.irad.conversion.gml.GmlConverter.ConvertGmlToEsriGraphic(GmlConverter.java:114)
at com.irad.conversion.gml.test.GmlConverterTest.ConvertGmlToEsriPolygonRingsGraphicTest(GmlConverterTest.java:194)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:45)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:42)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:30)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:263)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:68)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:47)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222)
at org.junit.runners.ParentRunner.run(ParentRunner.java:300)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:49)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
While, I couldn't figure out what was going on, I kept getting a message of Stub while running some Android API code. Keep in mind I was testing with JUnit outside of the official Android Test Project. And in that lies the problem.
Solution:
In order to run Android API code, you MUST run it on the emulator. Which to me stinks and for something as easy as converting colors like I was feels needless, but I guess I must now convert all my JUnit tests to the Android JUnit Project Sadly.
I had a problem running Tomcat through eclipse and received this error:
Port 8080 required by Tomcat v7.0 Server at localhost is already in use. The server may already be running in another process, or a system process may be using the port. To start this server you will need to stop the other process or change the port number(s).
I needed to figure out what was running on port 8080 and couldn't find any other tomcat item. I needed to shut down what ever was running on port 8080 so I could run tomcat through eclipse.
So this is what I figured out.
- Run this command: NETSTAT -p tcp -ano
- find the service running on 8080.
- read the PID.
- Press Ctrl+Alt+Dlt and go to the processes tab.
- Goto View->Select Columns-> Enable the PID column.
- Find the PID that matches your cmd list results and go ahead and kill it.
That should work and glad I could help.
There was a problem one of my peers found with Java JPA that got him stuck for a few hours. He told me to blog about it so here it is.
When you use the JAVA JPA library. You will pull results from the database. That’s exactly what the JPA lib does. Its like LINQ, but for Java.
So here is the problem. When pulling results from the JPA objects from the database, the JPA then caches all the objects. So every time after that, the cached results get returned instead of the most important information just placed in the Database. So, in order to get around this, you must call the “refresh” method. Or at least that’s what he told me to say. That method will then hit the DB again for another round trip and update all the objects on the JPA side.
That is all.