• Post Reply Bookmark Topic Watch Topic
  • New Topic

Even with the class defined, i get the error: org.hibernate.MappingException: Unknown entity

 
Jrcastro Ribeiro
Greenhorn
Posts: 29
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That's the class I want to create.

I already changed the imports and re-edited the annotations, but the error continued. I also changed update to create, but nothing has changed, I honestly do not know what's going on




The SessionBuild class




That's the cfg.xml file, as you can see, the class is correctly mapped, what can be wrong?




And here is the DAO factory for User class:



I dont know why a cant reach the User class, try everything, but with no sucess.

Any clues?
 
Paul Clapham
Sheriff
Posts: 21705
33
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


That line says that your Usuario class is in the br.com.javaparaweb.financeiro.usuario package. But the Usuario class which you posted is not in any package, so the mapping won't find it.

Or did you just omit the package declaration from what you posted?
 
Jrcastro Ribeiro
Greenhorn
Posts: 29
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Paul Clapham wrote:

That line says that your Usuario class is in the br.com.javaparaweb.financeiro.usuario package. But the Usuario class which you posted is not in any package, so the mapping won't find it.

Or did you just omit the package declaration from what you posted?


Thats the strcuture of the project:



As you can see, the class "Usuario" is inside the package

 
Rob Spoor
Sheriff
Posts: 20801
68
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jrcastro Ribeiro wrote:

Completely unrelated, but that code makes me cry. I hope that's been generated by your IDE, because I'd hate to have you waste time on writing such verbose code.

Unless you are using Java 6, you should make use of java.util.Objects:
I've just halved the number of lines of code of those two methods (equals went from 53 to 19, and that is with added { and }!), and made it more readable at the same time.

Note the calculation of hashCode of ativo. Boolean.valueOf(ativo) always returns either Boolean.TRUE or Boolean.FALSE, so this does not require any new objects. Java 8 has added static hashCode methods to all primitive wrapper classes, making it a lot easier to write hashCode methods. Especially for long, float and double it was quite verbose. Compare:
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!