Dave,
What does load.addAttribute() look like? Does it maintain both sides?
-D
On Jan 21, 2009, at 9:25 AM, David Whitehurst wrote:
> Hi:
>
> I'm doing reference data exactly like user-role but without
> predefined data. Load object has Attribute(s) When the save
> occurs, the relationship is not fulfilled in the load_attribute
> table (hence two id's per row). The mapping is provided below the
> test. Is sample data required to make this work. The table load
> and load_attribute are created.
>
> My test ...
>
>
> public void testAddLoadAttribute() throws Exception {
>
> Load load = dao.get(-1L);
> assertEquals(0, load.getAttributes().size()); // was 1
> expecting pre-load
>
> Attribute attribute = adao.getAttributeByName("Chains");
> load.addAttribute(attribute);
> load = dao.save(load);
> flush();
>
> load = dao.get(-1L);
> assertEquals(1, load.getAttributes().size());
>
> Load.java
>
> ...
> private Set<Attribute> attributes = new HashSet<Attribute>();
>
> @ManyToMany(fetch = FetchType.EAGER)
> @JoinTable(
> name="load_attribute",
> joinColumns = { @JoinColumn( name="load_id") },
> inverseJoinColumns = @JoinColumn( name="attribute_id")
> )
> public Set<Attribute> getAttributes() {
> return attributes;
> }
>
> public void setAttributes(Set<Attribute> attributes) {
> this.attributes = attributes;
> }
>
---------------------------------------------------------------------
To unsubscribe, e-mail:
[hidden email]
For additional commands, e-mail:
[hidden email]