MappingException: InvocationTargetException - java

I have a small problem here and hope that someone can help me out.
I wanna do a mapping from Object to Integer. The Object is marked as Fetchtype.Lazy.
When I do the mapping I get the following error message:
11:31:46,569 ERROR MappingProcessor:253 - Field mapping error -->
MapId: null
Type: null
Source parent class: ClassA
Source field name: MyObjectProperty
Source field type: null
Source field value: null
Dest parent class: ClassB
Dest field name: myIntegerProperty
Dest field type: java.lang.Integer
org.dozer.MappingException: java.lang.reflect.InvocationTargetException
at org.dozer.util.MappingUtils.throwMappingException(MappingUtils.java:88)
at org.dozer.util.ReflectionUtils.invoke(ReflectionUtils.java:258)
at org.dozer.propertydescriptor.GetterSetterPropertyDescriptor.invokeReadMethod(GetterSetterPropertyDescriptor.java:234)
at org.dozer.propertydescriptor.GetterSetterPropertyDescriptor.getPropertyValue(GetterSetterPropertyDescriptor.java:68)
at org.dozer.fieldmap.FieldMap.getSrcFieldValue(FieldMap.java:82)
InnerException:
Caused by: java.lang.IllegalStateException: Attempt to access an unloaded field of detached instance
I created a custom converter in dozer xml file but the converter is never called. I guess the application gets a problem before reaching this converter.
Funny thing is I can Map the fields successfully the other way around, so Integer to Object.
I appreciate any ideas, if you need further information please give me a word.
Thx to all.

If this were Hibernate I'd think a lazily loaded field were accessed outside of the Session the data bean is bound to.
I suggest loading the entity and mapping it in the same transaction would solve the problem. I don't know that for sure of course :)

Related

Exception when having Object type field in JPA #Entity: Caused by: org.hibernate.MappingException: property mapping has wrong number of columns

I have a JPA object that has field like that:
#Column(name = "check_close")
private Object check_close;
and the start I'm getting
Caused by: org.hibernate.MappingException: property mapping has wrong number of columns: rf.dom.billing.model.billing.TransactionRegistry.check_close type: object
Why the error is about the wrong number of columns? Shouldn't it point to the wront type used?
Changing type to some more valuable type like String made this error be never thrown, however, it is still intriguing for me why the error message was unrelated to the useless of Object type as JPA Entity field.

javers MANAGED_CLASS_MAPPING_ERROR

I did a refactoring and now my class B is not an Entity anymore but a Value.
If I try viewing the diff of an already audited Entity A, that contains a list of B's I am getting this exception: JaversException MANAGED_CLASS_MAPPING_ERROR: given javaClass 'class B' is mapped to ValueType, expected EntityType
Is there a recommended way how to fix this?
Sadly, looks like there is no workaround other than manually deleting snapshots of previous Entity.
I have created the issue for this case https://github.com/javers/javers/issues/753

DataRetrievalFailureException: '__type__' Not Found in Spring Data Neo4j

I have a Neo4j REST database set up and running and I was trying to access it using Spring Data Neo4j. The following code:
MyObject obj = myObjectRepository.findOne(1234L);
throws the following exception:
Exception in thread "main" org.springframework.dao.DataRetrievalFailureException: '__type__' on http://my.ip.addr.ess:7474/db/data/node/1234; nested exception is org.neo4j.graphdb.NotFoundException: '__type__' on http://my.ip.addr.ess:7474/db/data/node/1234
Note that if I navigate to http://my.ip.addr.ess:7474/db/data/node/1234, my object shows up correctly.
In my pom I have org.springframework.data:spring-data-neo4j-rest:2.1.0.BUILD-SNAPSHOT
I'm seeing the same issue. Seems I am required to have a type property on the db node obj. Why ?
You need to a add a property to your node called "__type__" and give it the value of your objects class name. E.g. in your example you would add to your node:
property: __type__ value: "MyObject"

SEAM Entity Query on field of sub object

Using seam-gen based code. I have an object "Classroom", which contains an instance of "Location". I want to query for classrooms but specifying a value on the Location object.
Something like 'select from Classroom where Location.State = "NY"'. When I try to bind a selectOneMenu with a list of states to #{ClassroomList.classroom.location.state} I'm getting errors.
Was getting a null pointer exception on Location. I'm assuming I need to instantiate a new "Location" on the Classroom object, but not sure where to do that. On the Classroom entity's constructor? On the ClassroomList backing bean (where the example object is bound to the ClassroomList JSP search fields)?
Yes, you need to instantiate ClassroomList.instance.Location. Because the ClassroomList.instance is not bound to the Database, this is not done automagically
Not sure if this is the best way, but I got it working.
I have a String exposed on my ClassroomList backing bean as "String locationState". My dropdown list of states binds to that
Then that's referenced in my restrictions as:
...
lower(classroom.location.state) like lower(concat(#{classroomList.locationState}, '%'))",
...
--
When I tried to instantiate ClassroomList.instance.Location, I would get:
javax.servlet.ServletException with message: "Id and clazz must not be null"
Not sure what's causing that?

dozer custom convertors for primitive types

the below url has an example on dozer custom convertors..
Map collection size in Dozer
but when i tried that example its giving the exception like this..
Type: null
Source parent class: dozerPackage.Source
Source field name: images
Source field type: class java.util.ArrayList
Source field value: [www, eee]
Dest parent class: dozerPackage.Destination
Dest field name: numOfImages
Dest field type: int
org.dozer.MappingException: Destination Type (int) is not accepted by this Custom Converter (dozerPackage.TestCustomFieldConverter)!
is there any way that i can return the primitive types from dozer custom convertors..
The short answer is no. This feature is not yet implemented. Please use old CustomConverter interface instead of DozerConverter to achieve the desired behavior.
Forum thread is here:
https://sourceforge.net/projects/dozer/forums/forum/452531/topic/3698691
Feature Request for tracking is here:
https://sourceforge.net/tracker/?func=detail&aid=2997109&group_id=133517&atid=727371

Categories

Resources