Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » JPA-RS: @OneToMany: invalid output when retrieving relationship link(GET relationship returns invalid JSON syntax in case an empty collection is POSTed)
JPA-RS: @OneToMany: invalid output when retrieving relationship link [message #1016471] Wed, 06 March 2013 15:15 Go to next message
Daniel Szalay is currently offline Daniel SzalayFriend
Messages: 15
Registered: February 2013
Junior Member
I am using GlassFish 3.1.2.2 with EclipseLink 2.5.0 nightly build 03/06.

TestEntity:

@Entity
public class UserTable implements Serializable {
	private static final long serialVersionUID = 8407966960002220704L;
	
	@Id
	@GeneratedValue
	private long id;
	@OneToMany(mappedBy="test", orphanRemoval=true, cascade=CascadeType.ALL, fetch=FetchType.EAGER)
	private List<Row> rows;

}


Row:

@Entity
public class Row implements Serializable {
	private static final long serialVersionUID = 8285524874443728506L;
	
	@Id
	@GeneratedValue
	private long id;
	@ManyToOne(optional=true)
	private TestEntity test;

}


Let's POST the following TestEntity's JSON:

{
"rows": [
     ]
}


Response 200 OK:

{
	"id":10,
	"_relationships":[
		{
			"_link":{
				"href":"http://localhost:8080/app/persistence/pu/entity/TestEntity/10/rows",
				"rel":"rows"
			}
		}
	],
	"rows":[
	]
}


GET http://localhost:8080/app/persistence/pu/entity/TestEntity/10/rows 200 OK:

{
	"]
}


Which is obviously invalid. The output is correct if I add some content to the collection.

[Updated on: Wed, 06 March 2013 15:26]

Report message to a moderator

Re: JPA-RS: @OneToMany: invalid output when retrieving relationship link [message #1017860 is a reply to message #1016471] Tue, 12 March 2013 16:48 Go to previous messageGo to next message
Gul Onural is currently offline Gul OnuralFriend
Messages: 12
Registered: February 2013
Junior Member
This is a bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=403042. Please check the status of the bug tomorrow and try with the newest load. The fix for this bug is likely to go in today.

[Updated on: Tue, 12 March 2013 17:51]

Report message to a moderator

icon14.gif  Re: JPA-RS: @OneToMany: invalid output when retrieving relationship link [message #1018301 is a reply to message #1017860] Wed, 13 March 2013 15:30 Go to previous message
Daniel Szalay is currently offline Daniel SzalayFriend
Messages: 15
Registered: February 2013
Junior Member
Thanks! Tested with EclipseLink 2.5.0 Nightly 20130313, and it works now correctly Razz
Previous Topic:Incorrect Cascade Discovery of new objects mapped from managed Embeddables
Next Topic:How to obtain the entity ID after persit from a trigger generated value
Goto Forum:
  


Current Time: Wed Apr 24 23:40:15 GMT 2024

Powered by FUDForum. Page generated in 0.02606 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top