Sam Mc Kee

Greenhorn
+ Follow
since Aug 20, 2010
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Sam Mc Kee

I have a REST service that accepts JSON in the request body. The method is defined as follows:



In the body of the request is a list of JSON objects representing ShoppingListItem objects, and this works fine. However, I would expect it also to work if the request body is empty--that the items variable would simply be null. However I get a 500 error before it even reaches my service when I post a request with an empty body.

Is this behavior normal/expected?

Thanks!
Sam

9 years ago
I've got a commandlink within a ui:repeat that is supposed to set some values on a bean. The loop looks like this.



The first three setPropertyActionListeners work just fine (they set booleans on the timecardBean) but the timecardBean year and month, not matter which one I put first throws an error that says " target="timecardBean.year": Illegal Syntax for Set Operation."

This is the set operation in TimecardBean:



That's it, nothing more to it. The getMonth() and getYear() methods on the Timecard (the variable for the ui:repeat) also return integers.

I've googled this to death and am at wit's end. Any advice would be greatly appreciated.

Thanks!
9 years ago
JSF
I'm trying to understand what exactly gets persisted automagically in a one-to-many relationship. I have a timecard object that owns a collection of timecard day objects and intend for simplicity's sake that this be a one-way relationship, i.e. you get the timecard days from the timecard object and not the other way around. So in my Timecard class I have this:

@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER)
@JoinColumn(name = "timecard_id")
private List<TimecardDay> days;

and in my TimecardDay object I have no relationship mapped. The timecard_id column is the PK of the timecard table and has a foreign key mapping from a timecard_id column in the timecard_days table.

After I create my Timecard tc object, must I em.persist(tc) first, then add all the timecard days to it and persist again?

When I tried just adding all the timecard days to the timecard object and then calling em.persist(tc) it gave me an error message saying it had a foreign key conflict on the statement "INSERT INTO MOPS_Timecard_Day (timecard_id, work_type_id, day) VALUES (?, ?, ?) bind => [0, 2, 5]", which suggests to me that there is no mechanism to set the parent ID on the child object unless I first persist the parent object, flush, read the parent id and set it on the child objects myself. Is this correct? Or is there a way to do the whole thing in a single persist call?

Sorry for the newbie question, but I've Googled this to death, and it's not at all clear to me why there's a @OneToMany annotation at all if I have to do it in two steps.

Thanks,
Sam