• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

Strange data retrieved in many to one mapping

 
Ranch Hand
Posts: 80
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello

I'm having a strange data received inmy jsp concerning many to one mapping
I receive like this from my mapped entity

gmc.gestaxi.domain.Veiculo@7843566e


This is my main class



And the related class



Any help please??

Thanks
 
Marshal
Posts: 25812
69
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's a Veiculo object. Why do you find that strange? Isn't that what you would expect?
 
Gil Carvalho
Ranch Hand
Posts: 80
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

Thank for posting

No, i expect a value like

A
B
C

values that i have in my database...

not this

gmc.gestaxi.domain.Veiculo@7843566e

This is unreadable, how can i achieve that??

Thank you
 
Paul Clapham
Marshal
Posts: 25812
69
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That's what the toString() method of Veiculo returns. Since you didn't override it, you get what the toString() method of Object returns. If you want something else, then write a toString() method which returns a suitable String object.
 
Gil Carvalho
Ranch Hand
Posts: 80
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank Paul

I'm lost, i understand that i have to use @Override in toString but wich field? The one i want to be listed?




Or just the one of the relationship, in this case is "empregadoVeiculos " to @Override?

Thanks and sorry for my silly questions but i'm new in hibernate

Regards
 
Paul Clapham
Marshal
Posts: 25812
69
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you don't like what the default toString() method returns for a Veiculo object, it's up to you to decide what you want instead.

Here's what the code would look like, as part of the Veiculo class:


 
Rancher
Posts: 2759
32
Eclipse IDE Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moved thread to java forum because it's not a spring question.
 
Gil Carvalho
Ranch Hand
Posts: 80
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you Paul

It was what i was looking for.


Best regards
 
And when my army is complete, I will rule the world! But, for now, I'm going to be happy with this tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic