Skip to main content

[JPA] BUG in the class weaver

8 replies [Last post]
vesuvius
Offline
Joined: 2007-06-02
Points: 0

Hi,

I encountered a bug in the class weaver. In the next post, I will provide a test case which causes the bug to appear. In short, however, I'm getting errors like this:

[pre]
Exception in thread "Main Thread" java.lang.NoSuchMethodError: _toplink_getorder1
at test.jpa.entities.OrderItem.getOrder1(OrderItem.java:49)
at test.jpa.TestJPA.testBug1(TestJPA.java:845)
at test.jpa.TestJPA.main(TestJPA.java:874)
[/pre]

Just to summarize, the error appears when there are two @ManyToOne relationships to one and the same Entity class and one of them is EAGER, while the other is LAZY.

The bug appears even with the latest GlassFish Release Candidate 2:
Oracle TopLink Essentials - 2.0 (Build b58a-rc2 (08/09/2007))

It appears both in Java SE and in Java EE (OC4J 10.1.3.3).

As I said, I will provide the test case in the next post.

Best regards,
Bisser

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
bisser
Offline
Joined: 2007-06-21
Points: 0

Published it: https://glassfish.dev.java.net/issues/show_bug.cgi?id=3516.

Thank you for your assistance.

tware
Offline
Joined: 2005-06-24
Points: 0

Appologies. 'been quite busy and haven't had a chance to look at this issue. This looks like a bug and I agree with the person above. You should file a big and including all the information you have provided in this post.

I suspect making the fetch types for the two Orders match will likely allow you to work around the problem.

vesuvius
Offline
Joined: 2007-06-02
Points: 0

Thank you all for replying!

I will log it in as a bug. I finally found the place where to do that.

vesuvius
Offline
Joined: 2007-06-02
Points: 0

Please, guys!

I have provided a bug report with a fully reproducible Test Case. Isn't there a single GlassFish Persistence team member who's interested in fixing this?

alexismp
Offline
Joined: 2005-01-06
Points: 0

Have you filed a bug? It would have better visibility.

vesuvius
Offline
Joined: 2007-06-02
Points: 0

The TEST CASE:

I have tried to reduce everything to the bare minimum, so that the bug will appear without too much clutter around it. Admittedly, this TEST CASE doesn't do much, but that's not the point. It took my quite a while to reduce my large business case to this little thing.

[b]1. Here's how to create and populate the tables:[/b]

[pre]
create table orders
(id number(18,0) not null);

alter table orders
add constraint orders_pk primary key (id);

create table order_items
(order_item_id number(18,0) not null,
order_id1 number(18,0) not null,
order_id2 number(18,0) not null);

alter table order_items
add constraint order_items_pk primary key (order_item_id);

alter table order_items
add constraint order_items_order1_fk foreign key (order_id1) references orders (id);

alter table order_items
add constraint order_items_order2_fk foreign key (order_id2) references orders (id);

insert into orders
values (1);

insert into order_items
values (1, 1, 1);

commit;
[/pre]

[b]2. Here's the Order entity:[/b]

[pre]
@Entity
@Table(name = "ORDERS")
public class Order implements Serializable {

@Id
@Column(name = "ID", nullable = false)
private Long id;

public Order() {
}

public Long getId() {
return id;
}

public void setId(Long id) {
this.id = id;
}
}
[/pre]

[b]3. Here's the OrderItem entity:[/b]

[pre]
@Entity
@Table(name = "ORDER_ITEMS")
public class OrderItem implements Serializable {

@Id
@Column(name="ORDER_ITEM_ID", nullable = false)
private Long id;

@ManyToOne(fetch=FetchType.EAGER)
@JoinColumn(name = "ORDER_ID1", referencedColumnName = "ID")
private Order order1;

@ManyToOne(fetch=FetchType.LAZY)
@JoinColumn(name = "ORDER_ID2", referencedColumnName = "ID")
private Order order2;

public OrderItem() {
}

public Long getId() {
return id;
}

public void setId(Long id) {
this.id = id;
}

public Order getOrder1() {
return order1;
}

public void setOrder1(Order order) {
this.order1 = order;
}

public Order getOrder2() {
return order2;
}

public void setOrder2(Order order) {
this.order2 = order;
}
}
[/pre]

[b]4. And finally, here's how to produce the bug:[/b]

[pre]
public void runBug() {
OrderItem oi = em.find(OrderItem.class, 1L);
System.out.println(oi.getOrder1().getId());
}
[/pre]

You'll see the stack trace that I published in the post above.

I have not added a persistence.xml. It's a straightforward task to create one.

Best regards,
Bisser

segueloscar
Offline
Joined: 2008-06-30
Points: 0

I have the same problem
and found the solution removing the parameter in @ManyToOne
example:

@ManyToOne
@JoinColumn(name = "ORDER_ID1", referencedColumnName = "ID")
private Order order1;

@ManyToOne
@JoinColumn(name = "ORDER_ID2", referencedColumnName = "ID")
private Order order2;

sorry for my english!

vesuvius
Offline
Joined: 2007-06-02
Points: 0

refresh...