-
Aug 1st, 2012, 11:48 AM
#1
Spring Data Rest Exception
I have a database view "Example"
Example
id name
100 HELLO
100 HELLO WORLD
200 TEST
200 TEST123
300 APPLE
Created entity and repository for Example using JPA Annotations
Entity: Example.java and the repository class ExampleRepository extends CrudRepository<Example, Long>
HTTP GET to the application:
http://localhost:8080/data
{
"_links" : [ {
"rel" : "data",
"href" : "http://localhost:8080/data/data"
} ]
}
http://localhost:8080/data/data
{
"_links" : [ {
"rel" : "data.Example.100",
"href" : "http://localhost:8080/data/data/100"
}, {
"rel" : "data.Example.100",
"href" : "http://localhost:8080/data/data/100"
}, {
"rel" : "data.Example.200",
"href" : "http://localhost:8080/data/data/200"
}, {
"rel" : "data.Example.200",
"href" : "http://localhost:8080/data/data/200"
}, {
"rel" : "data.Example.300",
"href" : "http://localhost:8080/data/data/300"
}, {
"rel" : "data.search",
"href" : "http://localhost:8080/data/data/search"
} ]
}
But when I was trying to get the attributes of Id:100, it is throwing exception
http://localhost:8080/data/example/100
org.springframework.orm.hibernate3.HibernateSystem Exception: More than one row with the given identifier was found: 100
Is there any way i can get all the attributes related to Example Id.
Any ideas, please help me out. Thanks
-
Aug 1st, 2012, 12:50 PM
#2
Spring Data REST 1.0.0.RC2 was released yesterday and includes a number of important bug fixes and changes the way entities are listed. In the latest stuff, entities are paged by default at 20 and returned directly. This will change how you approach this problem of duplicate IDs. Those entities should be listed inline (rather than returned as links as in the previous version of code), so you'll have access to both entities. That will not, however, solve the problem of having two entities with the same ID. You'll still only have one link with an ID of 100 on the end of it. But since entities are rendered inline by default in the latest code, you would be able to get access to both of them by just listing the entities.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules