Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7924403
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T17:44:00+00:00 2026-06-03T17:44:00+00:00

I am initializing a WebDataBinder with a PropertyEditor to handle the conversion of a

  • 0

I am initializing a WebDataBinder with a PropertyEditor to handle the conversion of a String to a Document object so that it can be saved to the database as such. (My Hibernate mapping requires it). This works fine.

My issue is when I display the DocumentRevision table, where the documentNumber is saved as a Document type, it displays something like the following: testapp.domain.document@1f93466

  • Do I have to make a new PropertyEditor which converts a Document type
    into a String?
  • How would I do that? (An example would be appreciated since I have only ever see the other way around, String –> Object)

I am using Spring 3.0 and Hibernate 3

Code:

Document.java mapping

@OneToMany(mappedBy="document_number", cascade = CascadeType.ALL)
private Set<DocumentRevision> documentRevisions;

public void setDocumentRevisions(Set<DocumentRevision> documentRevisions){
    this.documentRevisions = documentRevisions;
}

DocumentRevision.java mapping

@ManyToOne(cascade = CascadeType.ALL)
@JoinColumn(name="DOCUMENT_NUMBER")
private Document document_number; 

public void setDocument_number(Document document_number){
    this.document_number = document_number;
}

public Document getDocument_number(){
    return document_number;
}

The relationship between the two tables is that several DocumentRevisions can have the same DocumentNumber but a single DocumentRevision can only have one DocumentNumber

Part of the Controller:

class DocumentPropertyEditor extends PropertyEditorSupport {

@Override
public void setAsText(String text) throws IllegalArgumentException {
    Document value =  documentService.retrieveDocumentNumber(text);
    setValue(value);
}

@Override
public String getAsText() {
    Document d = (Document) getValue();
    return d != null ? String.valueOf(d.getDocumentNumber()) : "";
}
}
@InitBinder
public void initBinder(WebDataBinder binder) {
    binder.registerCustomEditor(Document.class, new DocumentPropertyEditor());
}

@RequestMapping(value="/list", method=RequestMethod.GET) 
public String getDocumentRevisionList(Model model) {
List<DocumentRevision> documentRevisions = documentRevisionService.retrieveAllDocumentRevisions();
model.addAttribute("documentRevisions", documentRevisions);
return "document-revision";

@RequestMapping(value="/add", method=RequestMethod.GET)
public String getDocumentRevision(Model model) {
DocumentRevision documentRevision = new DocumentRevision();
model.addAttribute("documentRevisionAttribute", documentRevision);
model.addAttribute("documentNumberList", documentService.retrieveAllDocumentNumbers());

return "new-documnent-revision";
}


@RequestMapping(value="/add", method=RequestMethod.POST)
public String postDocumentRevision(@ModelAttribute("documentRevisionAttribute") @Valid DocumentRevision documentRevision, BindingResult result) {

if(result.hasErrors()){
    return "new-document-revision";
}

documentRevisionService.createDocumentRevision(documentRevision);
return "redirect:/testapp/document-revision/list";  
}

the retrieveDocumentNumber(text) method:

public Document retrieveDocumentNumber(String text){
return (Document) this.sessionFactory.getCurrentSession().get(Document.class, text);
}

part of jsp page where DocumentRevision list is displayed:

 <c:forEach items="${documentRevisions}" var="documentRevision">
  <tr>
   <td><c:out value="${documentRevision.documentId}"/></td>
   <td><c:out value="${documentRevision.documentNumber}" /></td>
   <td><c:out value="${documentRevision.documentRState}" /></td>
   <td><a href="${addUrl}">Add</a></td>
  </tr>
 </c:forEach>

Thank you for your time and help!

/D

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T17:44:02+00:00Added an answer on June 3, 2026 at 5:44 pm

    Look likes it calls default toString() method. You can redefine this method in document class. In this case it will output what you want.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am iterating through the object and initializing all the properties of that object.
What options do I have when initializing string[] object?
When initializing a new Date object in JavaScript using the below call, I found
I am initializing a map map<string,int> ex; in C++. I could not find contains_key
I have certain initializing functions that I use to set up audit logging on
I am initializing map<string, vector<string> > as follows: map <string, vector<string> > dict; dict[USA].push_back(NYC);
I am initializing a mutable string and then logging it as follows. NSMutableString* mStr
I'm initializing a lot of string variables as follows: a, b, c, d, e,
I'm initializing an instance of a class that tests the equality of two formulas.
Possible Duplicate: Auto-Initializing C# Lists I have a list of integers that has a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.