[hibernate-issues] [Hibernate-JIRA] Commented: (ANN-632) @IndexColumn doesn't set value of index column

Dan Allen (JIRA) noreply at atlassian.com
Wed Jul 11 10:05:52 EDT 2007


    [ http://opensource.atlassian.com/projects/hibernate/browse/ANN-632?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_27446 ] 

Dan Allen commented on ANN-632:
-------------------------------

I mean come on, is space so scarce that you cannot include both examples. They are clearly not the same.  Yeah, sure, you can make the leap, but imagine someone just starting out who is not so familiar with Hibernate. Just add the example for @IndexColumn to supplement the @MapKey in respect of people's time. There are also thousands of people that spend a day or more trying to make that leap.

Also, it still doesn't answer the question as to why the child entity doesn't get updated.

Oh, and by the way. Clearly there is a mistake in that documentation because the Parent entity is displayed twice. The Child entity is missing. That makes it even MORE confusing.  Yes, I am being stubborn, but I feel that I have a case.

> @IndexColumn doesn't set value of index column
> ----------------------------------------------
>
>                 Key: ANN-632
>                 URL: http://opensource.atlassian.com/projects/hibernate/browse/ANN-632
>             Project: Hibernate Annotations
>          Issue Type: Bug
>          Components: documentation
>    Affects Versions: 3.3.0.ga
>            Reporter: Dan Allen
>
> I'm sure I will get screamed at for this, but the @IndexColumn just doesn't work with @OneToMany.  When I say it doesn't work, it means that I am a reasonable person and I have studied the documentation for at least 4 hours and I just cannot figure out how to make it work.  So either the documentation needs to be improved, or there is something wrong with Hibernate. I refuse to believe that I am this stupid.
> Here is my problem in a nutshell.  I have a Person and a collection of Jobs. The Jobs should be an indexed list based on the history that the person holds them.
> @Entity
> public class Person {
>     @Id @GeneratedValue
>     private long id;
>     @Column
>     private String name;
>     @OneToMany(cascade=ALL, fetch=LAZY, mappedBy = "job")
>     @IndexColumn(base = 1, name = "order")
>     private List<Job> jobs = new ArrayList<Job>();
>    // getters and setters
> }
> @Entity
> public class Job {
>     @Id @GeneratedValue
>     private long id;
>     @Column
>     private String name;
>     @ManyToOne
>     @JoinColumn(name="person_id")
>     private Person person;
>     @Column
>     private Integer order;
>    // getters and setters
> }
> If I do the following, I get NULL for order.
> Person person = new Person();
> person.setName("Chuck")
> Job job1 = new Job();
> job1.setName("sysadmin")
> job1.setPerson(person);
> person.getJobs().add(job1);
> Job job2 = new Job();
> jobs2.setName("network admin")
> job2.setPerson(person);
> person.getJobs().add(job2);
> entityManager.persist(person);
> Assume that the reason I am not assigning an order is more complex than this example. The point is that we want to see the order column populated with the index of the list.
> Now, if you give me the business about removing mappedBy, to that I will respond that by removing mappedBy, Hibernate tries to work with a person_job table, which I don't want. I want two tables, one for person and one for job.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        



More information about the hibernate-issues mailing list