[ 
https://issues.apache.org/jira/browse/OPENJPA-626?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12605672#action_12605672
 ] 

Fay Wang commented on OPENJPA-626:
----------------------------------

Hi Tim, I unzipped your source and made a couple of changes in your entity 
classes so that it can work with my DB2 backend (for example, change int4 to 
int, remove text column type, etc). I also modified the following entities 
classes to change "columnDefintion" to "name" in the JoinColumn annotations 
(without doing so, I won't be able to execute the create table ddl):  
(1)   change 
public class RouteStops {
        @ManyToOne(fetch = FetchType.EAGER, cascade = CascadeType.MERGE)
        @JoinColumn(columnDefinition = "bus_stop_id")
        private BusStops busStops;
...
        @ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.MERGE)
        @JoinColumn(name="route_id", columnDefinition = "route_id")
        private Routes routes;

to

public class RouteStops {
        @ManyToOne(fetch = FetchType.EAGER, cascade = CascadeType.MERGE)
        @JoinColumn(name = "bus_stop_id")
        private BusStops busStops;
...
        @ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.MERGE)
        @JoinColumn(name="route_id")
        private Routes routes;

(2)  from 
public class Schedules {
...
        @ManyToOne(fetch=FetchType.LAZY, cascade=CascadeType.MERGE)
        @JoinColumn(name="route_id", columnDefinition="route_id", 
nullable=false)
        private Routes routes;

to 

public class Schedules {
...
        @ManyToOne(fetch=FetchType.LAZY, cascade=CascadeType.MERGE)
        @JoinColumn(name="route_id", nullable=false)
        private Routes routes;

(3)  from 
 publc class TripStops {
...
        @ManyToOne(fetch=FetchType.EAGER, cascade=CascadeType.MERGE)
        @JoinColumn(columnDefinition="stop_id")
        private BusStops busStops;
...

        @ManyToOne(fetch=FetchType.LAZY, cascade=CascadeType.MERGE)
        @JoinColumn(columnDefinition="route_id")
        private Routes routes;
...     
        @ManyToOne(fetch=FetchType.EAGER, cascade=CascadeType.MERGE)
        @JoinColumn(columnDefinition="trip_id")
        private Trips trips;

to

public class TripStops {
...
        @ManyToOne(fetch=FetchType.EAGER, cascade=CascadeType.MERGE)
        @JoinColumn(name="stop_id")
        private BusStops busStops;
...
        @ManyToOne(fetch=FetchType.LAZY, cascade=CascadeType.MERGE)
        @JoinColumn(name="route_id")
        private Routes routes;
...
        @ManyToOne(fetch=FetchType.EAGER, cascade=CascadeType.MERGE)
        @JoinColumn(name="trip_id")
        private Trips trips;

I then called:

        BusStops b = em.find(BusStops.class, 1);
        ScheduleStops s = em.find(ScheduleStops.class, 1);

The generated SQL are valid in that the there is no synthesized join column 
name like  t0.BUSSTOP_STOP_ID or  t0.SCHEDULE_SCHEDULE_ID. In the case of  
BUSSTOP_STOP_ID, your original annotation in RouteStops  class is 

       @ManyToOne(fetch = FetchType.EAGER, cascade = CascadeType.MERGE)
        @JoinColumn(columnDefinition = "bus_stop_id")
        private BusStops busStops;

which does not have name field in the JoinColumn annotation. That explains why 
openjpa constructs a synthenized join column name. You might want to examine 
your JoinColumn annotations to make sure the name field is properly set. Still 
I am not clear why your entity class defnitions work fine in openjpa 1.0.x, but 
fail in openjpa 1.1.x ......







> @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-src-1.zip, 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.

Reply via email to