[
https://issues.apache.org/jira/browse/OPENJPA-626?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12604496#action_12604496
]
Tim Holloway commented on OPENJPA-626:
--------------------------------------
Thank you Fay. The damage is definitely done at SQL generation time, but since
the process looks like a series of refinements rather than a straight line, I'm
having difficulty homing in on where the bad field name comes from.
One thing I noticed, however, if my eyes don't deceive me. The JOIN field names
appear to be correct. Only the SELECT field name is wrong.
SELECT DISTINCT t0.route_id, t1.schedule_id, t1.schedule_stop_id, t2.stop_id,
t2.description, t2.elevation, t2.in_service_date, t2.inbound, t2.latitude,
t2.longitude, t2.out_service_date, t2.sheltered, t2.street1_block,
t3.street_direction_id, t3.description, t2.street1_name, t2.street1_qualifier,
t4.street_type_id, t4.description, t2.street2_block FROM public.schedules t0
LEFT OUTER JOIN public.schedule_stops t1 ON t0.schedule_id = t1.schedule_id
LEFT OUTER JOIN public.bus_stops t2 ON t1.bus_stop_id = t2.stop_id LEFT OUTER
JOIN public.lk_street_directions t3 ON t2.street1_direction =
t3.street_direction_id LEFT OUTER JOIN public.lk_street_types t4 ON
t2.street1_type = t4.street_type_id LEFT OUTER JOIN public.lk_street_directions
t5 ON t2.street2_direction = t5.street_direction_id ORDER BY t1.schedule_id
ASC, t1.stop_sequence ASC
Note that the 3d selected field is the offending "t1.schedule_stop_id", but the
actual join to the stops table is "LEFT OUTER JOIN public.bus_stops t2 ON
t1.bus_stop_id = t2.stop_id". Where t1.bus_stop_id properly reflects the
annotation:
@ManyToOne(fetch=FetchType.EAGER, cascade=CascadeType.MERGE)
@JoinColumn(name="bus_stop_id")
private BusStops busStop;
Linking to BusStops:
@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator =
"bus_stops_seq")
@SequenceGenerator(name = "bus_stops_seq", sequenceName =
"seq_bus_stops")
@Column(name = "stop_id", columnDefinition = "int4")
private Integer stopId;
The correct SQL column name in both cases should have been t1.bus_stop_id.
> @JoinColumn with name attribute causes exception on 1.2.0.
> -----------------------------------------------------------
>
> Key: OPENJPA-626
> URL: https://issues.apache.org/jira/browse/OPENJPA-626
> Project: OpenJPA
> Issue Type: Bug
> Affects Versions: 1.2.0
> Reporter: Michael Dick
> Attachments: OPENJPA-626-vars-1.txt
>
>
> Creating Issue on behalf of Tim Holloway. Here's his email to the dev mailing
> list :
> @ManyToOne(fetch=FetchType.EAGER, cascade=CascadeType.MERGE)
> @JoinColumn(name="bus_stop_id")
> private BusStops busStop;
> Works in release 1.0.2:
> SELECT t0.schedule_stop_id, t1.stop_id, t1.description, t1.elevation,
> t1.in_
> service_date, t1.inbound, t1.latitude, t1.longitude,
> t1.out_service_date, t1.sheltered, t1.street1_block,
> t2.street_direction_id, t2.description, t1.street1_name, t1.street1
> _qualifier, t3.street_type_id, t3.description, t1.street2_block,
> t4.street_direction_id, t4.description, t1.street2_name,
> t1.street2_qualifier, t5.street_type_id, t5.descrip
> tion, t1.waypoint, t0.clock_point, t0.comments, t0.in_service,
> t0.in_service_date, t0.inbound, t0.out_service_date, t0.outbound,
> t0.schedule_id, t0.stop_sequence, t0.terminu
> s, t0.transfer_point FROM public.schedule_stops t0 LEFT OUTER JOIN
> public.bus_stops t1 ON t0.bus_stop_id = t1.stop_id LEFT OUTER JOIN
> public.lk_street_directions t2 ON t1.st
> reet1_direction = t2.street_direction_id LEFT OUTER JOIN
> public.lk_street_types t3 ON t1.street1_type = t3.street_type_id LEFT
> OUTER JOIN public.lk_street_directions t4 ON t
> 1.street2_direction = t4.street_direction_id LEFT OUTER JOIN
> public.lk_street_types t5 ON t1.street2_type = t5.street_type_id WHERE
> t0.schedule_id = ? ORDER BY t0.stop_seque
> nce ASC [params=(int) 50]
> Uses synthesized column name instead of declared name in today's CVS
> snapshot:
> ERROR: column t0.busstop_stop_id does not exist {prepstmnt 17939164
> SELECT t0.schedule_stop_id, t1.stop_id, t1.description, t1.elevation,
> t1.in_service_date, t1.inbound, t1.latitude, t1.longitude,
> t1.out_service_date, t1.sheltered, t1.street1_block,
> t2.street_direction_id, t2.description, t1.street1_name,
> t1.street1_qualifier, t3.street_type_id, t3.description,
> t1.street2_block, t4.street_direction_id, t4.description,
> t1.street2_name, t1.street2_qualifier, t5.street_type_id,
> t5.description, t1.waypoint, t0.clock_point, t0.comments, t0.in_service,
> t0.in_service_date, t0.inbound, t0.out_service_date, t0.outbound,
> t0.SCHEDULE_SCHEDULE_ID, t0.stop_sequence, t0.terminus,
> t0.transfer_point
> FROM public.schedule_stops t0
> LEFT OUTER JOIN public.bus_stops t1
> ON t0.BUSSTOP_STOP_ID = t1.stop_id
> LEFT OUTER JOIN public.lk_street_directions t2
> ON t1.street1_direction = t2.street_direction_id
> LEFT OUTER JOIN public.lk_street_types t3 ON t1.street1_type =
> t3.street_type_id LEFT OUTER JOIN public.lk_street_directions t4 ON
> t1.street2_direction = t4.street_direction_id LEFT OUTER JOIN
> public.lk_street_types t5 ON t1.street2_type = t5.street_type_id WHERE
> t0.SCHEDULE_SCHEDULE_ID = ? ORDER BY t0.stop_sequence ASC [params=(int)
> 50]} [code=0, state=42703]
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.