We help IT Professionals succeed at work.

Help with Spring/Hibernate many to many CRUD interface?

dkim18
dkim18 asked
on
Hi,

can you help me with how I need to design the interface for CRUD ops using the Spring/Hibernate objects below?
I am new to hibernate and I am not seeing how I need to design the interface for CRUD ops.

Do I collect values for both author and citation in one form?
Or Do I collect the citation value first then create another form to collect the author value then attach this author record below the citation  like parent/child view?

Is there an example that uses to spring/hibernate to do insert  manyToMany relation tables?

Author(authorid,lastname,firstname)
Citation(citationid, articletitle,articletype)


public class Author {

@ManyToMany
@JoinTable(name="citation_author",
joinColumns={@JoinColumn(name="authorid")},
inverseJoinColumns={@JoinColumn(name="citationid")})
public List<Citation> getCitations() {return citations;}
}

public class Citation {
@ManyToMany
@JoinTable(name="citation_author",
joinColumns={@JoinColumn(name="citationid")},
inverseJoinColumns={@JoinColumn(name="authorid")})
public List<Author> getAuthors() {return authors;}
}

Open in new window

I forgot about the association table:
author_citation (authorid,citationid)

Open in new window

Comment
Watch Question

Commented:
Spring Hibernate Tutorial

First off, it seems you are getting confused between your presentation layer and your model layer.

You are working on your underlying persisteance layer which is part of your object model.  Therefore how you load your information is irrelevant in terms of the design of your persistence model.

Notwithstanding that, there is no reason you couldn't take either approach at your presentation layer depending on the business use case for extracting these values.

Author

Commented:
yes, I need help with presentation. Any suggestions?