• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Spring/hibernate manytomany mapping problems using annotations

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,

I'm trying to build a Spring/Hibernate application on top of an existing database structure and having some problems when trying to map my Java objects to existing data using annotations. The code below is an amalgamation from a number of tutorials and general web trawling so my understand isn't as full as it should be, particularly being new to both Spring and Hibernate!

The actual problem is that when the servlet returns the JSON back to JS in my page, it seems to be creating an infinate recursion problem that manages to take down Tomcat(!!).
When I make the JS call to fetch JSON representing a Route I want to get back the Route fields along with a List/Set of which checkpoints a route uses rather than this massive recursion I'm getting.

Returned JSON:
[{"name":"External Test Patrol","duration":-2209161600000,"maxTime":-2209161000000,"minTime":-2209161600000,"oid":15138,"routePoints":[{"oid":25703,"pointNo":4,"route":{"name":"External Test Patrol","duration":-2209161600000,"maxTime":-2209161000000,"minTime":-2209161600000,"oid":15138,"routePoints":[{"oid":25703,"pointNo":4,"route":{"name":"External Test Patrol","duration":-2209161600000,"maxTime":-2209161000000,"minTime":-2209161600000,"oid":15138,"routePoints":[{"oid":25703,"pointNo":4,"route":{"name":"External Test Patrol","duration":-2209161600000,"maxTime":-2209161000000,"minTime":-2209161600000,"oid":15138,"routePoints":[{"oid":25703,"pointNo":4,"route":{"name":"External Test Patrol","duration":-2209161600000,"maxTime":-2209161000000,"minTime":-2209161600000,"oid":15138,"routePoints":[{"oid":25703,"pointNo":4,"route":{"name":"External Test Patrol","duration":-2209161600000,"maxTime":-2209161000000,"minTime":-2209161600000,"oid":15138,"routePoints":[{"oid":25703,"pointNo":4,"route":{"name":"External Test Patrol","duration":-2209161600000,"maxTime":-2209161000000,"minTime":-2209161600000,"oid":15138,"routePoints":[{"oid":25703,"pointNo":4,"route":{"name":"External Test Patrol","duration":-2209161600000,"maxTime":-2209161000000,"minTime":-2209161600000,"oid":15138,"routePoints":[{"oid":25703,"pointNo":4,"route" ............. etc etc

Both Spring and Hibernate are recent (summer 2011) versions.

The tables of interest in the DB:
ROUTES {OID, name, <other fields of no significance>}
CHECKPOINTS {OID, name, <other dull fields of no interest>}
ROUTEPOINTS {OID, route*, checkpoint*, pointno} //where route is a FK ref to ROUTES.OID and checkpoint is FK ref to CHECKPOINTS.OID

A route may have several checkpoints, a checkpoint may feature in several routes. So a manytomany relationship.

Some Java:

Route.java represents a Route object


CheckPoint.java


RoutePoint.java - the mapping table


RouteCheckPointPK.java
 
reply
    Bookmark Topic Watch Topic
  • New Topic