I am using Dozer to map objects. But I am getting an wired error message
Property active for class com.edfx.adb.persist.entity.Customer cannot
be read from.
in the Dozer Mapping Editor of Eclipse, I have Dozer plugin installed in Eclipse. This is the mapping I have:
<mapping>
<class-a>com.edfx.adb.persist.entity.Customer</class-a>
<class-b>com.edfx.adb.web.dto.CustomerDTO</class-b>
<field>
<a get-method="isActive">active</a>
<b get-method="isActive">active</b>
<a-hint>java.lang.Boolean</a-hint>
<b-hint>java.lang.Boolean</b-hint>
</field>
</mapping>
Here active is the field with type boolean in Customer and CustomerDTO class.
I am unable to remove or hide the error message. Also don't know why it is showing. And for this error Eclipse showing error in whole project which is undesirable.
Any information would be very helpful to me.
I would try deleting hints. In this scenario I think you don´t need them.
But for best solution can you post your code for the entity and the DTO.
Related
I am creating a server with Glassfish, Jersey, and a MySQL database
My EntityManager used to work but now does not
Here's an example of a simple method that used to work but now does not
#GET
#Path("movie/{id}")
#JSONP
#Produces({"application/javascript", MediaType.APPLICATION_JSON})
public Movie getMovie(#PathParam("id") int id) {
EntityManager em = (EntityManager) context.getAttribute("em");
Movie requestedMovie = em.find(Movie.class, id);
return requestedMovie;
}
It now returns java.lang.IllegalArgumentException: Unknown Entity bean class: class data.entry.Movie, please verify that this class has been marked with the #Entity annotation.
Bizarrely, it still does this even when I use git to roll my code back to a commit where I know it used to work.
Additionally, the code still works on my teammate's laptops.
The issue started when I attempted to add annotations to another class, and attempted to test it. This error started appearing. I then rolled my code back to previous commits to undo my changes, but I am still getting the error.
I have tried rebooting my laptop multiple times as well to no avail.
Any idea what could cause entity manager to stop being able to find entities?
Please try to remove built file.
It's mostly related to IDE cache / build cache.
Unknown Entity bean class: class data.entry.Movie, please verify that this class has been marked with the #Entity annotation.
And please check this too.
Solved the issue by uninstalling/reinstalling glassfish
My model.xml file contain following code fragment. but I don't know why they are used.I used Spring and Hibernate technologies to build the project. hopes some expert explanation about this code fragment and the attributes?
<one-to-one fetch-type="lazy" name="followUp" type="FollowUp" synthetic="true"
nullable="true" access="frozen">
<documentation>Synthetic property of the latest follow ups made for
this Prescription.
</documentation>
</one-to-one>
i habe a question concerning Dozer Bean Mapping. I have the follwing xml configuration parts (i don´t understand some of this facts):
<mapping>
<class-a>
entity.template.TemplateEntity
</class-a>
<class-b>dto.template.TemplateDto
</class-b>
<field>
<a set-method="setLang" get-method="getLang">lang</a>
<b set-method="setLang" get-method="getLang">lang</b>
<a-hint>entity.template.TemplateLanguageEntity</a-hint>
<b-hint>dto.template.TemplateLanguageDto</b-hint>
</field>
</mapping>
What is the concret meaning of "set-method="setLang" get-method="getLang""?
What does the Dozer Bean Mapper do in this part? There is no other configuration, which describes, how to two collection should be mapped?
<a-hint>entity.template.TemplateLanguageEntity</a-hint>
<b-hint>dto.template.TemplateLanguageDto</b-hint>
Does the Dozer Mapper map all fields automatically, which are founded by them if no configuration was set?
Thanks for helping !
Greetz
Marwief
What is the concret meaning of "set-method="setLang" get-method="getLang""?
Beans that might have unorthodox getter and setter methods, Dozer support user specified setter and getter methods.To make a bi-directional mapping in this case, look at the following example below.
The source field in element A specifies a custom setter method and getter method using attributes.
<field>
<a set-method="placeValue" get-method="buildValue">value</a>
<b>value</b>
</field>
What does the Dozer Bean Mapper do in this part? There is no other configuration, which describes, how to two collection should be mapped?
Understand the Custom set() and get() methods dozer documentation.
Lets take for example if we are mapping a String to an ArrayList by calling the addIntegerToList() method.
Note that this is defined as a one-way field type since we can not map an ArrayList to a String.
<!-- we can not map a ArrayList to a String,
hence the one-way mapping -->
<field type="one-way">
<a>integerStr</a>
<b set-method="addIntegerToList">integerList</b>
</field>
Does the Dozer Mapper map all fields automatically, which are founded by them if no configuration was set?
Yes, Dozer Mapper maps all the fields automatically from class-A to class-B iff both the field names are same.
I am using Hibernate as ORM for my project. I use mysql Database
I have a table "Products" inside DB "catalog".
I have put the #Table(name="Products",schema="catalog") annotation for the entity Products in my application.
However when I try to run the application I get the below exception. Can you please help me resolve this issue?
Exception:
Exception in thread "main" org.hibernate.HibernateException: Missing table:Products
at org.hibernate.cfg.Configuration.validateSchema(Configuration.java:1281)
at org.hibernate.tool.hbm2ddl.SchemaValidator.validate(SchemaValidator.java:155)
at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:508)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1769)
at org.eros.purchase.db.utils.HibernateUtil.configure(HibernateUtil.java:17)
at Test.main(Test.java:14)
Any thoughts on how I can fix this?
Please update your hibernate.cfg.xml file by adding this property
<property name="hibernate.hbm2ddl.auto">create</property>
or
<property name="hibernate.hbm2ddl.auto">update</property>
I got the same exception from hibernate. In my case, it was because the database user was not properly authorized to see the tables. The tables were definitively there on the database.
After I assigned the roles db_datareader to the user for this database it worked.
However, in another case, where the tables weren't actually there, I got exactly the same exception from hibernate. I cases where the tables are there, I think hibernate might show no more information because of security reasons.
I think your mapping is referring to User table which is actually not in database. .
so check your xml mapping of hibernate
package com.mypackage;
import javax.persistence.Entity;//first check two annotations belong to right package
import javax.persistence.Table;
#Entity
#Table(name = "Products",schema="catalog")
public class Products{
//entity attributes
}
//second check mapping file (if use)i.e register Products class with right spelling
// or third check Hibernate util if we are register mapping class like this
public class CustomHibernateUtil{
private static Configuration getConfiguration(){
configuration.addAnnotatedClass(Products.class);
return configuration;
}
}
I'm using Xstream to serialize a EJB entity class to be transferred by a web service, but it also writes the database specific information in this case the following code. Is it possible to omit this information?
<oracle.toplink.essentials.internal.helper.DatabaseField>
<scale>0</scale>
<length>255</length>
<precision>0</precision>
<isUnique>false</isUnique>
<isNullable>true</isNullable>
<isUpdatable>true</isUpdatable>
<isInsertable>true</isInsertable>
<columnDefinition></columnDefinition>
<name>ZIPCODEID</name>
<table>
<name>ZIPCODE</name>
<tableQualifier></tableQualifier>
<qualifiedName>ZIPCODE</qualifiedName>
<uniqueConstraints/>
</table>
<sqlType>4</sqlType>
<index>0</index>
</oracle.toplink.essentials.internal.helper.DatabaseField>
From FAQ:
How do I specify that a field should not be serialized?
Make it transient, specify it with XStream.omitField() or annotate it with #XStreamOmitField
EclipseLink (open sourced from TopLink) JAXB has extensions specifically for mapping JPA entities to XML:
For more information see:
http://wiki.eclipse.org/EclipseLink/Examples/MOXy/JPA
If you use openJPA you can detach the object to get the naked entity.
Check ->
http://openjpa.apache.org/builds/1.0.0/apache-openjpa-1.0.0/docs/manual/ref_guide_remote.html
Hope it helps...