[scala] JPA question

View: New views
12 Messages — Rating Filter:   Alert me  

Parent Message unknown [scala] JPA question

by Balthazar Crowley :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

All,

I'm working on a Lift application, and am taking advantage of Scala's expressive power. The application generates a JPA-persistence back-end. i'm running into a strange situation regarding entity relations. Below the signature line is a rendition of what's happening. When the app persists an instance of MySampleFuContainer it breaks complaining 

... 
12:46:14,150  WARN JDBCExceptionReporter:77 - SQL Error: 0, SQLState: 01004 
12:46:14,151 ERROR JDBCExceptionReporter:78 - Data truncation: Data too long for column 'mysamplingmumble_' at row 
...

When i pull the instance of MySamplingFu out and persist it, everything goes through as expected. In the trace below res5 is bound to the entity manager and res4 is bound to an instance of MyBasicFu pulled from the instance of the container.

scala> res5.getTransaction().begin()
res5.getTransaction().begin()
res5.getTransaction().begin()

scala> res5.persist( res4 )
res5.persist( res4 )
res5.persist( res4 )

scala> res5.getTransaction().commit()
res5.getTransaction().commit()
res5.getTransaction().commit()
12:12:27,363 DEBUG SQL:401 - insert into lingo_production.MyBasicFu_table (id, integer_, string_1, string_2, string_3, string_4, string_5, string_6, uuid, idSuper) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
Hibernate: insert into lingo_production.MyBasicFu_table (id, integer_, string_1, string_2, string_3, string_4, string_5, string_6, uuid, idSuper) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?) 
scala>

Regards,

Balthazar

@Entity
@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
@Table(name = "MySampleFuContainer_table", catalog = "lingo_production", uniqueConstraints = { @UniqueConstraint(columnNames = "uuid") })
public class MySampleFuContainer extends Container {

    public final MySamplingFu mysamplingmumble_;

    public MySampleFuContainer(MySamplingFu p1) {
        mysamplingmumble_ = p1;
    }

    public <R, A> R accept(net.dslver.sampler.model.lingo.pipeline.persistence.sql.Container.Visitor<R, A> v, A arg) {
        return v.visit(this, arg);
    }

    public boolean equals(Object o) {
        if (this == o) return true;
        if (o instanceof net.dslver.sampler.model.lingo.pipeline.persistence.sql.MySampleFuContainer) {
            net.dslver.sampler.model.lingo.pipeline.persistence.sql.MySampleFuContainer x = (net.dslver.sampler.model.lingo.pipeline.persistence.sql.MySampleFuContainer) o;
            return this.mysamplingmumble_.equals(x.mysamplingmumble_);
        }
        return false;
    }

    public int hashCode() {
        return this.mysamplingmumble_.hashCode();
    }

    private String uuid;

    private String id;

    @JoinColumn(name = "mysamplingmumble_", unique = false, nullable = true, insertable = true, updatable = true)
    @OneToOne
    public MySamplingFu getMysamplingmumble_() {
        return this.mysamplingmumble_;
    }

    public void setUuid(String uuid) {
        this.uuid = uuid;
    }

    @Column(name = "uuid", unique = false, nullable = true, insertable = true, updatable = true)
    public String getUuid() {
        return this.uuid;
    }

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

    @Id
    @GeneratedValue(generator = "system-uuid")
    @GenericGenerator(name = "system-uuid", strategy = "uuid")
    @Column(name = "id", unique = false, nullable = true, insertable = true, updatable = true)
    public String getId() {
        return this.id;
    }
}

@Entity
@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
public abstract class MySamplingFu implements java.io.Serializable {

    public abstract <R, A> R accept(MySamplingFu.Visitor<R, A> v, A arg);

    public interface Visitor<R, A> {

        public R visit(net.dslver.sampler.model.lingo.pipeline.persistence.sql.MyPerfFu p, A arg);

        public R visit(net.dslver.sampler.model.lingo.pipeline.persistence.sql.MyBindFu p, A arg);
    }

    @Id
    @GeneratedValue(generator = "system-uuid")
    @GenericGenerator(name = "system-uuid", strategy = "uuid")
    private String idSuper;
}


@Entity
@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
@Table(name = "MyBasicFu_table", catalog = "lingo_production", uniqueConstraints = { @UniqueConstraint(columnNames = "uuid") })
public class MyBasicFu extends MySamplingFu {

    public final String string_1, string_2, string_3, string_4, string_5, string_6;

    public final Integer integer_;

    public MyBasicFu(String p1, String p2, String p3, String p4, Integer p5, String p6, String p7) {
        string_1 = p1;
        string_2 = p2;
        string_3 = p3;
        string_4 = p4;
        integer_ = p5;
        string_5 = p6;
        string_6 = p7;
    }

    public <R, A> R accept(net.dslver.sampler.model.lingo.pipeline.persistence.sql.MySamplingFu.Visitor<R, A> v, A arg) {
        return v.visit(this, arg);
    }

    public boolean equals(Object o) {
        if (this == o) return true;
        if (o instanceof net.dslver.sampler.model.lingo.pipeline.persistence.sql.MyBasicFu) {
            net.dslver.sampler.model.lingo.pipeline.persistence.sql.MyBasicFu x = (net.dslver.sampler.model.lingo.pipeline.persistence.sql.MyBasicFu) o;
            return this.string_1.equals(x.string_1) && this.string_2.equals(x.string_2) && this.string_3.equals(x.string_3) && this.string_4.equals(x.string_4) && this.integer_.equals(x.integer_) && this.string_5.equals(x.string_5) && this.string_6.equals(x.string_6);
        }
        return false;
    }

    public int hashCode() {
        return 37 * (37 * (37 * (37 * (37 * (37 * (this.string_1.hashCode()) + this.string_2.hashCode()) + this.string_3.hashCode()) + this.string_4.hashCode()) + this.integer_.hashCode()) + this.string_5.hashCode()) + this.string_6.hashCode();
    }

    private String uuid;

    private String id;

    @Column(name = "string_1", unique = false, nullable = true, insertable = true, updatable = true)
    public String getString_1() {
        return this.string_1;
    }

    @Column(name = "string_2", unique = false, nullable = true, insertable = true, updatable = true)
    public String getString_2() {
        return this.string_2;
    }

    @Column(name = "string_3", unique = false, nullable = true, insertable = true, updatable = true)
    public String getString_3() {
        return this.string_3;
    }

    @Column(name = "string_4", unique = false, nullable = true, insertable = true, updatable = true)
    public String getString_4() {
        return this.string_4;
    }

    @Column(name = "string_5", unique = false, nullable = true, insertable = true, updatable = true)
    public String getString_5() {
        return this.string_5;
    }

    @Column(name = "string_6", unique = false, nullable = true, insertable = true, updatable = true)
    public String getString_6() {
        return this.string_6;
    }

    @Column(name = "integer_", unique = false, nullable = true, insertable = true, updatable = true)
    public Integer getInteger_() {
        return this.integer_;
    }

    public void setUuid(String uuid) {
        this.uuid = uuid;
    }

    @Column(name = "uuid", unique = false, nullable = true, insertable = true, updatable = true)
    public String getUuid() {
        return this.uuid;
    }

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

    @Id
    @GeneratedValue(generator = "system-uuid")
    @GenericGenerator(name = "system-uuid", strategy = "uuid")
    @Column(name = "id", unique = false, nullable = true, insertable = true, updatable = true)
    public String getId() {
        return this.id;
    }
}

--
Balthazar Crowley
Resident Magician
DSLver.net

Parent Message unknown Re: [scala] JPA question

by Balthazar Crowley :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Derek,

Thanks for the tip about the hibernate.show_sql property. The column it's complaining about is not the Id column, but the column that should be inferred as a relation. It's a field that represents a OneToOne composition relation. It looks like -- instead of just using the Id of the thing contained it's using the serialization of the object. 

Best wishes,

--greg

On Fri, Jun 12, 2009 at 3:56 PM, Derek Chen-Becker <derek@...> wrote:
Balthazar Crowley wrote:
> All,
>
> I'm working on a Lift application, and am taking advantage of Scala's
> expressive power. The application generates a JPA-persistence back-end.
> i'm running into a strange situation regarding entity relations. Below
> the signature line is a rendition of what's happening. When the app
> persists an instance of MySampleFuContainer it breaks complaining

Nothing in your code jumps out at me, but since you're using Hibernate I
would suggest adding the

<property name="hibernate.show_sql" value="true" />

property to your persistence.xml and emailing us the output when the
persist fails. At least that should show what it's trying to insert.
It's possible that it expects a uuid type to be a certain length and
somehow it's getting something longer. What is the system-uuid generator?

Derek



--
Balthazar Crowley
Resident Magician
DSLver.com

Re: [scala] JPA question

by Derek Chen-Becker-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Balthazar Crowley wrote:
> Derek,
>
> Thanks for the tip about the hibernate.show_sql property. The column
> it's complaining about is not the Id column, but the column that should
> be inferred as a relation. It's a field that represents a OneToOne
> composition relation. It looks like -- instead of just using the Id of
> the thing contained it's using the serialization of the object.

Right, well, what I meant was that for the other side of the one-to-one
the @Id is a String uuid, which is what really should be stored as the
foreign key. If you're truly getting a serialized version of the object
then that really seems like a Hibernate bug.

Derek

Re: [scala] JPA question

by Balthazar Crowley :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Derek,

The show_sql property was on, it turns out, but the sql statement doesn't display the values for the inserts. What's weirder is that JoinColumn + OneToOne annotations are causing the generated DDL to specify the type as tinyblob instead of the type of the id field. So, it really is attempting to serialize the element contained instead of the foreign key.

Regards,

Balthazar

On Sun, Jun 14, 2009 at 6:23 AM, Derek Chen-Becker <java@...> wrote:
Balthazar Crowley wrote:
> Derek,
>
> Thanks for the tip about the hibernate.show_sql property. The column
> it's complaining about is not the Id column, but the column that should
> be inferred as a relation. It's a field that represents a OneToOne
> composition relation. It looks like -- instead of just using the Id of
> the thing contained it's using the serialization of the object.

Right, well, what I meant was that for the other side of the one-to-one
the @Id is a String uuid, which is what really should be stored as the
foreign key. If you're truly getting a serialized version of the object
then that really seems like a Hibernate bug.

Derek



--
Balthazar Crowley
Resident Magician
DSLver.com

Re: [scala] JPA question

by Derek Chen-Becker-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Balthazar Crowley wrote:
> Derek,
>
> The show_sql property was on, it turns out, but the sql statement
> doesn't display the values for the inserts. What's weirder is that
> JoinColumn + OneToOne annotations are causing the generated DDL to
> specify the type as tinyblob instead of the type of the id field. So, it
> really is attempting to serialize the element contained instead of the
> foreign key.

Yeah, that definitely sounds like a bug. I wonder if anything similar
has been reported on Hibernate's JIRA...

Derek

Re: [scala] JPA question

by John Nilsson :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,

I think the showSql property has been deprecated in favor of log4j loggers.

If you set the log4j level to TRACE for org.hibernate you'll get
everything Hibernate has to say about what it is doing. Can't remember
which one it is, but I know one of the loggers will give you the
values used in queries at the TRACE level.

BR,
John

On Tue, Jun 16, 2009 at 2:18 AM, Balthazar
Crowley<balthazar.crowley@...> wrote:

> Derek,
> The show_sql property was on, it turns out, but the sql statement doesn't
> display the values for the inserts. What's weirder is that JoinColumn +
> OneToOne annotations are causing the generated DDL to specify the type as
> tinyblob instead of the type of the id field. So, it really is attempting to
> serialize the element contained instead of the foreign key.
> Regards,
> Balthazar
>
> On Sun, Jun 14, 2009 at 6:23 AM, Derek Chen-Becker <java@...>
> wrote:
>>
>> Balthazar Crowley wrote:
>> > Derek,
>> >
>> > Thanks for the tip about the hibernate.show_sql property. The column
>> > it's complaining about is not the Id column, but the column that should
>> > be inferred as a relation. It's a field that represents a OneToOne
>> > composition relation. It looks like -- instead of just using the Id of
>> > the thing contained it's using the serialization of the object.
>>
>> Right, well, what I meant was that for the other side of the one-to-one
>> the @Id is a String uuid, which is what really should be stored as the
>> foreign key. If you're truly getting a serialized version of the object
>> then that really seems like a Hibernate bug.
>>
>> Derek
>
>
>
> --
> Balthazar Crowley
> Resident Magician
> DSLver.com
>

Re: [scala] JPA question

by Derek Chen-Becker-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

John Nilsson wrote:
> Hi,
>
> I think the showSql property has been deprecated in favor of log4j loggers.
>
> If you set the log4j level to TRACE for org.hibernate you'll get
> everything Hibernate has to say about what it is doing. Can't remember
> which one it is, but I know one of the loggers will give you the
> values used in queries at the TRACE level.

Good to know. Thanks!


Re: [scala] JPA question

by Meredith Gregory :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

All,

i had a similar problem and found the source of the issues. Spse you have a container hierarchy (CTop <- C2) side-by-side with a contained hierarchy (CThing <- CThing1). The inheritance at the top of the container hierarchy, CTop, causes hibernate to bail on tracking the relations and punt to embedded values instead. Rewriting the top to be a @MappedSuperClass fixes the problem in this specific case. However, if your hierarchy is deep, you're screwed.

If anybody has a suggestion for a workaround, i'm all ears. The problem is that it would appear that both Mr Crowley and i are generating Java + JPA code. So, the solution needs to be algorithmic and not 1-off.

Perhaps the best solution is to find an alternative to hibernate as this is a particularly irritating bug.

Best wishes,

--greg

@Entity
@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
abstract class CTop {
   ...
   @Id
    @GeneratedValue(generator = "system-uuid")
    @GenericGenerator(name = "system-uuid", strategy = "uuid")
    private String id_CTop;
}

@Entity
@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
abstract class CThing {
   ...
   @Id
    @GeneratedValue(generator = "system-uuid")
    @GenericGenerator(name = "system-uuid", strategy = "uuid")
    private String id_CThing;
}

@Entity
@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
@Table(name = "C2_table", catalog = "mydb_production", uniqueConstraints = { @UniqueConstraint(columnNames = "uuid") })
class C2 extends CTop {
   CThing thing;
...
  @OneToOne
    @JoinColumn
    public CThing getThing() {
        return this.thing;
    }
    public void setThing( CThing thing ) {
        this.thing = thing;
    }

@Column(name = "uuid", unique = false, nullable = true, insertable = true, updatable = true)
    public String getUuid() {
        return this.uuid;
    }

    public void setUuid(String uuid) {
        this.uuid = uuid;
    }

    @Id
    @GeneratedValue(generator = "system-uuid")
    @GenericGenerator(name = "system-uuid", strategy = "uuid")
    @Column(name = "id", unique = false, nullable = true, insertable = true, updatable = true)
    public String getId() {
        return this.id;
    }

}

@Entity
@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
@Table(name = "CThing1_table", catalog = "mydb_production", uniqueConstraints = { @UniqueConstraint(columnNames = "uuid") })
class CThing1 extends CThing {
...
  // lots of ground type fields

@Column(name = "uuid", unique = false, nullable = true, insertable = true, updatable = true)
    public String getUuid() {
        return this.uuid;
    }

    public void setUuid(String uuid) {
        this.uuid = uuid;
    }

    @Id
    @GeneratedValue(generator = "system-uuid")
    @GenericGenerator(name = "system-uuid", strategy = "uuid")
    @Column(name = "id", unique = false, nullable = true, insertable = true, updatable = true)
    public String getId() {
        return this.id;
    }

}


On Tue, Jun 16, 2009 at 1:45 PM, Derek Chen-Becker <java@...> wrote:
John Nilsson wrote:
> Hi,
>
> I think the showSql property has been deprecated in favor of log4j loggers.
>
> If you set the log4j level to TRACE for org.hibernate you'll get
> everything Hibernate has to say about what it is doing. Can't remember
> which one it is, but I know one of the loggers will give you the
> values used in queries at the TRACE level.

Good to know. Thanks!




--
L.G. Meredith
Managing Partner
Biosimilarity LLC
1219 NW 83rd St
Seattle, WA 98117

+1 206.650.3740

http://biosimilarity.blogspot.com

Parent Message unknown Re: [scala] JPA question

by Meredith Gregory :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Kris,

Thanks for the suggestion. i've now got a tiny little example that compiles on its own that illustrates the problem. Changing the inheritance strategy to JOINED makes no difference. Hibernate still does the wrong thing.

Best wishes,

--greg

On Mon, Jun 22, 2009 at 8:55 AM, Kris Nuttycombe <kris.nuttycombe@...> wrote:
This may be off the mark, but I'm wondering if the reason that you're
having difficulty with the parallel inheritance hierarchy problem is
not your use of TABLE_PER_CLASS inheritance. In my application, I have
a similar construct, but I am using JOINED_TABLE inheritance. This
allows for a normal foreign key relationship to be created in the
database between C2_table and the base table for CThing, with the
result that Hibernate will generate the query for CThing member as a
union. Using table per class inheritance, I would expect Hibernate to
need to synthesize an additional dtype field in C2_table along with
the key column in order to enforce the uniqueness of the keys to the
joined entities, and I don't believe that it does this.

I'm not sure how the fact that the code is generated is particularly
relevant; surely if it's possible to hand-write a successful solution,
then your code generator could be made aware of how to construct a
viable solution?

Kris

On Fri, Jun 19, 2009 at 8:47 PM, Meredith
Gregory<lgreg.meredith@...> wrote:
> All,
>
> i had a similar problem and found the source of the issues. Spse you have a
> container hierarchy (CTop <- C2) side-by-side with a contained hierarchy
> (CThing <- CThing1). The inheritance at the top of the container hierarchy,
> CTop, causes hibernate to bail on tracking the relations and punt to
> embedded values instead. Rewriting the top to be a @MappedSuperClass fixes
> the problem in this specific case. However, if your hierarchy is deep,
> you're screwed.
>
> If anybody has a suggestion for a workaround, i'm all ears. The problem is
> that it would appear that both Mr Crowley and i are generating Java + JPA
> code. So, the solution needs to be algorithmic and not 1-off.
>
> Perhaps the best solution is to find an alternative to hibernate as this is
> a particularly irritating bug.
>
> Best wishes,
>
> --greg
>
> @Entity
> @Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
> abstract class CTop {
>    ...
>    @Id
>     @GeneratedValue(generator = "system-uuid")
>     @GenericGenerator(name = "system-uuid", strategy = "uuid")
>     private String id_CTop;
> }
>
> @Entity
> @Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
> abstract class CThing {
>    ...
>    @Id
>     @GeneratedValue(generator = "system-uuid")
>     @GenericGenerator(name = "system-uuid", strategy = "uuid")
>     private String id_CThing;
> }
>
> @Entity
> @Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
> @Table(name = "C2_table", catalog = "mydb_production", uniqueConstraints = {
> @UniqueConstraint(columnNames = "uuid") })
> class C2 extends CTop {
>    CThing thing;
> ...
>   @OneToOne
>     @JoinColumn
>     public CThing getThing() {
>         return this.thing;
>     }
>     public void setThing( CThing thing ) {
>         this.thing = thing;
>     }
>
> @Column(name = "uuid", unique = false, nullable = true, insertable = true,
> updatable = true)
>     public String getUuid() {
>         return this.uuid;
>     }
>
>     public void setUuid(String uuid) {
>         this.uuid = uuid;
>     }
>
>     @Id
>     @GeneratedValue(generator = "system-uuid")
>     @GenericGenerator(name = "system-uuid", strategy = "uuid")
>     @Column(name = "id", unique = false, nullable = true, insertable = true,
> updatable = true)
>     public String getId() {
>         return this.id;
>     }
>
> }
>
> @Entity
> @Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
> @Table(name = "CThing1_table", catalog = "mydb_production",
> uniqueConstraints = { @UniqueConstraint(columnNames = "uuid") })
> class CThing1 extends CThing {
> ...
>   // lots of ground type fields
>
> @Column(name = "uuid", unique = false, nullable = true, insertable = true,
> updatable = true)
>     public String getUuid() {
>         return this.uuid;
>     }
>
>     public void setUuid(String uuid) {
>         this.uuid = uuid;
>     }
>
>     @Id
>     @GeneratedValue(generator = "system-uuid")
>     @GenericGenerator(name = "system-uuid", strategy = "uuid")
>     @Column(name = "id", unique = false, nullable = true, insertable = true,
> updatable = true)
>     public String getId() {
>         return this.id;
>     }
>
> }
>
>
> On Tue, Jun 16, 2009 at 1:45 PM, Derek Chen-Becker <java@...>
> wrote:
>>
>> John Nilsson wrote:
>> > Hi,
>> >
>> > I think the showSql property has been deprecated in favor of log4j
>> > loggers.
>> >
>> > If you set the log4j level to TRACE for org.hibernate you'll get
>> > everything Hibernate has to say about what it is doing. Can't remember
>> > which one it is, but I know one of the loggers will give you the
>> > values used in queries at the TRACE level.
>>
>> Good to know. Thanks!
>>
>
>
>
> --
> L.G. Meredith
> Managing Partner
> Biosimilarity LLC
> 1219 NW 83rd St
> Seattle, WA 98117
>
> +1 206.650.3740
>
> http://biosimilarity.blogspot.com
>



--
L.G. Meredith
Managing Partner
Biosimilarity LLC
1219 NW 83rd St
Seattle, WA 98117

+1 206.650.3740

http://biosimilarity.blogspot.com

Re: [scala] JPA question

by Meredith Gregory :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Kris,

Here is a link to the self-contained example that now uses just Java. i included the target dir in the repo to speed up investigation, but you can just blow that away and build from scratch. The example is currently written to Java1.6, but also exhibits the same behavior under Java1.5. To run the example

> svn co http://svn.biosimilarity.com/src/open/codesamples/trunk/hibernate
...
> env PATH=<path-to-java1.6>:$PATH JAVA_HOME=<path-to-java1.6> mvn clean compile process-classes

If you switch comment and decl at line 22 in src/main/java/maxb/hbex2/MySampleFuContainer.java then you see the error. The schema goes from

create table lingo_production.MySampleFuContainer_table (
        id_AbstractContainer varchar(255) not null,
        varchar(255) not null,
        uuid varchar(255),
        mysamplingmumble__idSuper varchar(255),
        primary key (id),
        unique (uuid)
    );

to

create table lingo_production.MySampleFuContainer_table (
        id_AbstractContainer varchar(255) not null,
        id varchar(255),
        mysamplingmumble_ tinyblob,
        uuid varchar(255),
        primary key (id_AbstractContainer),
        unique (id_AbstractContainer)
    );

Best wishes,

--greg

On Mon, Jun 22, 2009 at 1:38 PM, Meredith Gregory <lgreg.meredith@...> wrote:
Kris,

Thanks for the suggestion. i've now got a tiny little example that compiles on its own that illustrates the problem. Changing the inheritance strategy to JOINED makes no difference. Hibernate still does the wrong thing.

Best wishes,

--greg


On Mon, Jun 22, 2009 at 8:55 AM, Kris Nuttycombe <kris.nuttycombe@...> wrote:
This may be off the mark, but I'm wondering if the reason that you're
having difficulty with the parallel inheritance hierarchy problem is
not your use of TABLE_PER_CLASS inheritance. In my application, I have
a similar construct, but I am using JOINED_TABLE inheritance. This
allows for a normal foreign key relationship to be created in the
database between C2_table and the base table for CThing, with the
result that Hibernate will generate the query for CThing member as a
union. Using table per class inheritance, I would expect Hibernate to
need to synthesize an additional dtype field in C2_table along with
the key column in order to enforce the uniqueness of the keys to the
joined entities, and I don't believe that it does this.

I'm not sure how the fact that the code is generated is particularly
relevant; surely if it's possible to hand-write a successful solution,
then your code generator could be made aware of how to construct a
viable solution?

Kris

On Fri, Jun 19, 2009 at 8:47 PM, Meredith
Gregory<lgreg.meredith@...> wrote:
> All,
>
> i had a similar problem and found the source of the issues. Spse you have a
> container hierarchy (CTop <- C2) side-by-side with a contained hierarchy
> (CThing <- CThing1). The inheritance at the top of the container hierarchy,
> CTop, causes hibernate to bail on tracking the relations and punt to
> embedded values instead. Rewriting the top to be a @MappedSuperClass fixes
> the problem in this specific case. However, if your hierarchy is deep,
> you're screwed.
>
> If anybody has a suggestion for a workaround, i'm all ears. The problem is
> that it would appear that both Mr Crowley and i are generating Java + JPA
> code. So, the solution needs to be algorithmic and not 1-off.
>
> Perhaps the best solution is to find an alternative to hibernate as this is
> a particularly irritating bug.
>
> Best wishes,
>
> --greg
>
> @Entity
> @Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
> abstract class CTop {
>    ...
>    @Id
>     @GeneratedValue(generator = "system-uuid")
>     @GenericGenerator(name = "system-uuid", strategy = "uuid")
>     private String id_CTop;
> }
>
> @Entity
> @Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
> abstract class CThing {
>    ...
>    @Id
>     @GeneratedValue(generator = "system-uuid")
>     @GenericGenerator(name = "system-uuid", strategy = "uuid")
>     private String id_CThing;
> }
>
> @Entity
> @Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
> @Table(name = "C2_table", catalog = "mydb_production", uniqueConstraints = {
> @UniqueConstraint(columnNames = "uuid") })
> class C2 extends CTop {
>    CThing thing;
> ...
>   @OneToOne
>     @JoinColumn
>     public CThing getThing() {
>         return this.thing;
>     }
>     public void setThing( CThing thing ) {
>         this.thing = thing;
>     }
>
> @Column(name = "uuid", unique = false, nullable = true, insertable = true,
> updatable = true)
>     public String getUuid() {
>         return this.uuid;
>     }
>
>     public void setUuid(String uuid) {
>         this.uuid = uuid;
>     }
>
>     @Id
>     @GeneratedValue(generator = "system-uuid")
>     @GenericGenerator(name = "system-uuid", strategy = "uuid")
>     @Column(name = "id", unique = false, nullable = true, insertable = true,
> updatable = true)
>     public String getId() {
>         return this.id;
>     }
>
> }
>
> @Entity
> @Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
> @Table(name = "CThing1_table", catalog = "mydb_production",
> uniqueConstraints = { @UniqueConstraint(columnNames = "uuid") })
> class CThing1 extends CThing {
> ...
>   // lots of ground type fields
>
> @Column(name = "uuid", unique = false, nullable = true, insertable = true,
> updatable = true)
>     public String getUuid() {
>         return this.uuid;
>     }
>
>     public void setUuid(String uuid) {
>         this.uuid = uuid;
>     }
>
>     @Id
>     @GeneratedValue(generator = "system-uuid")
>     @GenericGenerator(name = "system-uuid", strategy = "uuid")
>     @Column(name = "id", unique = false, nullable = true, insertable = true,
> updatable = true)
>     public String getId() {
>         return this.id;
>     }
>
> }
>
>
> On Tue, Jun 16, 2009 at 1:45 PM, Derek Chen-Becker <java@...>
> wrote:
>>
>> John Nilsson wrote:
>> > Hi,
>> >
>> > I think the showSql property has been deprecated in favor of log4j
>> > loggers.
>> >
>> > If you set the log4j level to TRACE for org.hibernate you'll get
>> > everything Hibernate has to say about what it is doing. Can't remember
>> > which one it is, but I know one of the loggers will give you the
>> > values used in queries at the TRACE level.
>>
>> Good to know. Thanks!
>>
>
>
>
> --
> L.G. Meredith
> Managing Partner
> Biosimilarity LLC
> 1219 NW 83rd St
> Seattle, WA 98117
>
> +1 206.650.3740
>
> http://biosimilarity.blogspot.com
>



--
L.G. Meredith
Managing Partner
Biosimilarity LLC
1219 NW 83rd St
Seattle, WA 98117

+1 206.650.3740

http://biosimilarity.blogspot.com



--
L.G. Meredith
Managing Partner
Biosimilarity LLC
1219 NW 83rd St
Seattle, WA 98117

+1 206.650.3740

http://biosimilarity.blogspot.com

Parent Message unknown Re: [Lift] Re: [scala] JPA question

by Meredith Gregory :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Derek,

i completely concur. i wanted to give it a serious go, however, before i abandoned it. The issue is that so much of the incumbent technology goes across this object-relational boundary, i needed a simple case to justify walking away from this technology. This example provides it. To see just how non-complex it is, let me state it in common sense terms.
  1. Suppose we are building an app for a manufacturing firm, and the firm ships out its goods in different kinds of containers: plastic-coated cardboard boxes, metal boxes, etc.
  2. Suppose that different kinds of materials go into different kinds of boxes, and sometimes medicinal or toxic substances go into these containers; but, every container gets a manifest. When the container contains these materials that need to be handled with care or attention, the manifest is a special kind of certified manifest.
We might imagine that this firm has already constructed an object model that looks like

abstract class Container { ...; Manifest getManifest(); void setManifest( Manifest manifest ); ... }
class CardboardContainer extends Container { ... }
class MetalContainer extends Container { ... }
abstract class Manifest { ... }
class StdManifest extends Manifest { ... }
class CertifiedManifest extends Manifest { ... }

We need to work with their existing infrastructure. However, this situation/model breaks Hibernate's implementation of JPA. That such a simple situation would cause problems indicates to me that these technologies have never been used in any significant way in production -- otherwise they would have bumped into such a common case. If i'm wrong about something, here, i'd love to be disabused of my misunderstanding(s). Currently, i feel i have enough justification to go to a different kind of solution, such as a LINQ-based solution.

Best wishes,

--greg

On Mon, Jun 22, 2009 at 5:46 PM, Derek Chen-Becker <dchenbecker@...> wrote:
For sufficiently complex relationships, JPA is not a good fit. Beyond a certain point it's usually simpler to roll your own. I think that this is somewhat of a failing of the model, but it's not a simple problem to solve in the generic case.

Derek


On Mon, Jun 22, 2009 at 6:45 PM, Derek Chen-Becker <dchenbecker@...> wrote:
Ah, sorry, I lost track of the thread.


On Mon, Jun 22, 2009 at 4:55 PM, Meredith Gregory <lgreg.meredith@...> wrote:
Derek,

You are correct and i noted and reported this on Scala on Friday. However, if you have a chain of the form

AbstractClass <- Class <-contains- AbstractClass <-Class <-contains- ...

The @MappedSuperclass solution fails at level 2.

Best wishes,

--greg


On Mon, Jun 22, 2009 at 3:52 PM, Derek Chen-Becker <dchenbecker@...> wrote:
Something I just want to throw out into the discussion: Since you're using table-per-class, having a @Table annotation on AbstractContainer doesn't do anything since abstract classes can't have instances. Tables are only generated for abstract classes if you're using a JOINED inheritance strategy. You might want to look at using the MappedSuperclass annotation for the abstract base class instead. If I change the AbstractContainer def to:

@MappedSuperclass
public abstract class AbstractContainer implements java.io.Serializable {

and then modify MySampleFuContainer to:

public class MySampleFuContainer extends AbstractContainer {

then I seem to get the proper schema:


    create table lingo_production.MySampleFuContainer_table (
        id varchar(255) not null,

        uuid varchar(255),
        mysamplingmumble__idSuper varchar(255),
        primary key (id),
        unique (uuid)
    );


Having said that, I think that the behavior you're currently seeing appears to be a bug.

Derek


On Mon, Jun 22, 2009 at 3:43 PM, Meredith Gregory <lgreg.meredith@...> wrote:
Kris,

Here is a link to the self-contained example that now uses just Java. i included the target dir in the repo to speed up investigation, but you can just blow that away and build from scratch. The example is currently written to Java1.6, but also exhibits the same behavior under Java1.5. To run the example

> svn co http://svn.biosimilarity.com/src/open/codesamples/trunk/hibernate
...
> env PATH=<path-to-java1.6>:$PATH JAVA_HOME=<path-to-java1.6> mvn clean compile process-classes

If you switch comment and decl at line 22 in src/main/java/maxb/hbex2/MySampleFuContainer.java then you see the error. The schema goes from

create table lingo_production.MySampleFuContainer_table (
        id_AbstractContainer varchar(255) not null,
        varchar(255) not null,
        uuid varchar(255),
        mysamplingmumble__idSuper varchar(255),
        primary key (id),
        unique (uuid)
    );

to

create table lingo_production.MySampleFuContainer_table (
        id_AbstractContainer varchar(255) not null,
        id varchar(255),
        mysamplingmumble_ tinyblob,
        uuid varchar(255),
        primary key (id_AbstractContainer),
        unique (id_AbstractContainer)
    );

Best wishes,

--greg


On Mon, Jun 22, 2009 at 1:38 PM, Meredith Gregory <lgreg.meredith@...> wrote:
Kris,

Thanks for the suggestion. i've now got a tiny little example that compiles on its own that illustrates the problem. Changing the inheritance strategy to JOINED makes no difference. Hibernate still does the wrong thing.

Best wishes,

--greg


On Mon, Jun 22, 2009 at 8:55 AM, Kris Nuttycombe <kris.nuttycombe@...> wrote:
This may be off the mark, but I'm wondering if the reason that you're
having difficulty with the parallel inheritance hierarchy problem is
not your use of TABLE_PER_CLASS inheritance. In my application, I have
a similar construct, but I am using JOINED_TABLE inheritance. This
allows for a normal foreign key relationship to be created in the
database between C2_table and the base table for CThing, with the
result that Hibernate will generate the query for CThing member as a
union. Using table per class inheritance, I would expect Hibernate to
need to synthesize an additional dtype field in C2_table along with
the key column in order to enforce the uniqueness of the keys to the
joined entities, and I don't believe that it does this.

I'm not sure how the fact that the code is generated is particularly
relevant; surely if it's possible to hand-write a successful solution,
then your code generator could be made aware of how to construct a
viable solution?

Kris

On Fri, Jun 19, 2009 at 8:47 PM, Meredith
Gregory<lgreg.meredith@...> wrote:
> All,
>
> i had a similar problem and found the source of the issues. Spse you have a
> container hierarchy (CTop <- C2) side-by-side with a contained hierarchy
> (CThing <- CThing1). The inheritance at the top of the container hierarchy,
> CTop, causes hibernate to bail on tracking the relations and punt to
> embedded values instead. Rewriting the top to be a @MappedSuperClass fixes
> the problem in this specific case. However, if your hierarchy is deep,
> you're screwed.
>
> If anybody has a suggestion for a workaround, i'm all ears. The problem is
> that it would appear that both Mr Crowley and i are generating Java + JPA
> code. So, the solution needs to be algorithmic and not 1-off.
>
> Perhaps the best solution is to find an alternative to hibernate as this is
> a particularly irritating bug.
>
> Best wishes,
>
> --greg
>
> @Entity
> @Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
> abstract class CTop {
>    ...
>    @Id
>     @GeneratedValue(generator = "system-uuid")
>     @GenericGenerator(name = "system-uuid", strategy = "uuid")
>     private String id_CTop;
> }
>
> @Entity
> @Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
> abstract class CThing {
>    ...
>    @Id
>     @GeneratedValue(generator = "system-uuid")
>     @GenericGenerator(name = "system-uuid", strategy = "uuid")
>     private String id_CThing;
> }
>
> @Entity
> @Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
> @Table(name = "C2_table", catalog = "mydb_production", uniqueConstraints = {
> @UniqueConstraint(columnNames = "uuid") })
> class C2 extends CTop {
>    CThing thing;
> ...
>   @OneToOne
>     @JoinColumn
>     public CThing getThing() {
>         return this.thing;
>     }
>     public void setThing( CThing thing ) {
>         this.thing = thing;
>     }
>
> @Column(name = "uuid", unique = false, nullable = true, insertable = true,
> updatable = true)
>     public String getUuid() {
>         return this.uuid;
>     }
>
>     public void setUuid(String uuid) {
>         this.uuid = uuid;
>     }
>
>     @Id
>     @GeneratedValue(generator = "system-uuid")
>     @GenericGenerator(name = "system-uuid", strategy = "uuid")
>     @Column(name = "id", unique = false, nullable = true, insertable = true,
> updatable = true)
>     public String getId() {
>         return this.id;
>     }
>
> }
>
> @Entity
> @Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
> @Table(name = "CThing1_table", catalog = "mydb_production",
> uniqueConstraints = { @UniqueConstraint(columnNames = "uuid") })
> class CThing1 extends CThing {
> ...
>   // lots of ground type fields
>
> @Column(name = "uuid", unique = false, nullable = true, insertable = true,
> updatable = true)
>     public String getUuid() {
>         return this.uuid;
>     }
>
>     public void setUuid(String uuid) {
>         this.uuid = uuid;
>     }
>
>     @Id
>     @GeneratedValue(generator = "system-uuid")
>     @GenericGenerator(name = "system-uuid", strategy = "uuid")
>     @Column(name = "id", unique = false, nullable = true, insertable = true,
> updatable = true)
>     public String getId() {
>         return this.id;
>     }
>
> }
>
>
> On Tue, Jun 16, 2009 at 1:45 PM, Derek Chen-Becker <java@...>
> wrote:
>>
>> John Nilsson wrote:
>> > Hi,
>> >
>> > I think the showSql property has been deprecated in favor of log4j
>> > loggers.
>> >
>> > If you set the log4j level to TRACE for org.hibernate you'll get
>> > everything Hibernate has to say about what it is doing. Can't remember
>> > which one it is, but I know one of the loggers will give you the
>> > values used in queries at the TRACE level.
>>
>> Good to know. Thanks!
>>
>
>
>
> --
> L.G. Meredith
> Managing Partner
> Biosimilarity LLC
> 1219 NW 83rd St
> Seattle, WA 98117
>
> +1 206.650.3740
>
> http://biosimilarity.blogspot.com
>



--
L.G. Meredith
Managing Partner
Biosimilarity LLC
1219 NW 83rd St
Seattle, WA 98117

+1 206.650.3740

http://biosimilarity.blogspot.com



--
L.G. Meredith
Managing Partner
Biosimilarity LLC
1219 NW 83rd St
Seattle, WA 98117

+1 206.650.3740

http://biosimilarity.blogspot.com








--
L.G. Meredith
Managing Partner
Biosimilarity LLC
1219 NW 83rd St
Seattle, WA 98117

+1 206.650.3740

http://biosimilarity.blogspot.com





--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Lift" group.
To post to this group, send email to liftweb@...
To unsubscribe from this group, send email to liftweb%2Bunsubscribe@...
For more options, visit this group at http://groups.google.com/group/liftweb?hl=en
-~----------~----~----~----~------~----~------~--~---




--
L.G. Meredith
Managing Partner
Biosimilarity LLC
1219 NW 83rd St
Seattle, WA 98117

+1 206.650.3740

http://biosimilarity.blogspot.com

Re: [Lift] Re: [scala] JPA question

by Derek Chen-Becker-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

In my eyes this is a bug. The JPA model should be able to handle this.

Derek

On Tue, Jun 23, 2009 at 10:29:07AM -0700, Meredith Gregory wrote:

> Derek,
>
> i completely concur. i wanted to give it a serious go, however, before i
> abandoned it. The issue is that so much of the incumbent technology goes
> across this object-relational boundary, i needed a simple case to justify
> walking away from this technology. This example provides it. To see just how
> non-complex it is, let me state it in common sense terms.
>
>    1. Suppose we are building an app for a manufacturing firm, and the firm
>    ships out its goods in different kinds of containers: plastic-coated
>    cardboard boxes, metal boxes, etc.
>    2. Suppose that different kinds of materials go into different kinds of
>    boxes, and sometimes medicinal or toxic substances go into these containers;
>    but, every container gets a manifest. When the container contains these
>    materials that need to be handled with care or attention, the manifest is a
>    special kind of certified manifest.
>
> We might imagine that this firm has already constructed an object model that
> looks like
>
> abstract class Container { ...; Manifest getManifest(); void setManifest(
> Manifest manifest ); ... }
> class CardboardContainer extends Container { ... }
> class MetalContainer extends Container { ... }
> abstract class Manifest { ... }
> class StdManifest extends Manifest { ... }
> class CertifiedManifest extends Manifest { ... }
>
> We need to work with their existing infrastructure. However, this
> situation/model breaks Hibernate's implementation of JPA. That such a simple
> situation would cause problems indicates to me that these technologies have
> never been used in any significant way in production -- otherwise they would
> have bumped into such a common case. If i'm wrong about something, here, i'd
> love to be disabused of my misunderstanding(s). Currently, i feel i have
> enough justification to go to a different kind of solution, such as a
> LINQ-based solution.
>
> Best wishes,
>
> --greg
>
> On Mon, Jun 22, 2009 at 5:46 PM, Derek Chen-Becker <dchenbecker@...>wrote:
>
> > For sufficiently complex relationships, JPA is not a good fit. Beyond a
> > certain point it's usually simpler to roll your own. I think that this is
> > somewhat of a failing of the model, but it's not a simple problem to solve
> > in the generic case.
> >
> > Derek
> >
> >
> > On Mon, Jun 22, 2009 at 6:45 PM, Derek Chen-Becker <dchenbecker@...>wrote:
> >
> >> Ah, sorry, I lost track of the thread.
> >>
> >>
> >> On Mon, Jun 22, 2009 at 4:55 PM, Meredith Gregory <
> >> lgreg.meredith@...> wrote:
> >>
> >>> Derek,
> >>>
> >>> You are correct and i noted and reported this on Scala on Friday.
> >>> However, if you have a chain of the form
> >>>
> >>> AbstractClass <- Class <-contains- AbstractClass <-Class <-contains- ...
> >>>
> >>> The @MappedSuperclass solution fails at level 2.
> >>>
> >>> Best wishes,
> >>>
> >>> --greg
> >>>
> >>>
> >>> On Mon, Jun 22, 2009 at 3:52 PM, Derek Chen-Becker <
> >>> dchenbecker@...> wrote:
> >>>
> >>>> Something I just want to throw out into the discussion: Since you're
> >>>> using table-per-class, having a @Table annotation on AbstractContainer
> >>>> doesn't do anything since abstract classes can't have instances. Tables are
> >>>> only generated for abstract classes if you're using a JOINED inheritance
> >>>> strategy. You might want to look at using the MappedSuperclass annotation
> >>>> for the abstract base class instead. If I change the AbstractContainer def
> >>>> to:
> >>>>
> >>>> @MappedSuperclass
> >>>> public abstract class AbstractContainer implements java.io.Serializable
> >>>> {
> >>>>
> >>>> and then modify MySampleFuContainer to:
> >>>>
> >>>> public class MySampleFuContainer extends AbstractContainer {
> >>>>
> >>>> then I seem to get the proper schema:
> >>>>
> >>>>     create table lingo_production.MySampleFuContainer_table (
> >>>>         id varchar(255) not null,
> >>>>         uuid varchar(255),
> >>>>         mysamplingmumble__idSuper varchar(255),
> >>>>         primary key (id),
> >>>>         unique (uuid)
> >>>>     );
> >>>>
> >>>>
> >>>> Having said that, I think that the behavior you're currently seeing
> >>>> appears to be a bug.
> >>>>
> >>>> Derek
> >>>>
> >>>>
> >>>> On Mon, Jun 22, 2009 at 3:43 PM, Meredith Gregory <
> >>>> lgreg.meredith@...> wrote:
> >>>>
> >>>>> Kris,
> >>>>>
> >>>>> Here<http://svn.biosimilarity.com/src/open/codesamples/trunk/hibernate/>is a link to the self-contained example that now uses just Java. i included
> >>>>> the target dir in the repo to speed up investigation, but you can just blow
> >>>>> that away and build from scratch. The example is currently written to
> >>>>> Java1.6, but also exhibits the same behavior under Java1.5. To run the
> >>>>> example
> >>>>>
> >>>>> > svn co
> >>>>> http://svn.biosimilarity.com/src/open/codesamples/trunk/hibernate
> >>>>> ...
> >>>>> > env PATH=<path-to-java1.6>:$PATH JAVA_HOME=<path-to-java1.6> mvn
> >>>>> clean compile process-classes
> >>>>>
> >>>>> If you switch comment and decl at line 22 in
> >>>>> src/main/java/maxb/hbex2/MySampleFuContainer.java then you see the error.
> >>>>> The schema goes from
> >>>>>
> >>>>> create table lingo_production.MySampleFuContainer_table (
> >>>>>         id_AbstractContainer varchar(255) not null,
> >>>>>         varchar(255) not null,
> >>>>>         uuid varchar(255),
> >>>>>         mysamplingmumble__idSuper varchar(255),
> >>>>>         primary key (id),
> >>>>>         unique (uuid)
> >>>>>     );
> >>>>>
> >>>>> to
> >>>>>
> >>>>> create table lingo_production.MySampleFuContainer_table (
> >>>>>         id_AbstractContainer varchar(255) not null,
> >>>>>         id varchar(255),
> >>>>>         mysamplingmumble_ tinyblob,
> >>>>>         uuid varchar(255),
> >>>>>         primary key (id_AbstractContainer),
> >>>>>         unique (id_AbstractContainer)
> >>>>>     );
> >>>>>
> >>>>> Best wishes,
> >>>>>
> >>>>> --greg
> >>>>>
> >>>>>
> >>>>> On Mon, Jun 22, 2009 at 1:38 PM, Meredith Gregory <
> >>>>> lgreg.meredith@...> wrote:
> >>>>>
> >>>>>> Kris,
> >>>>>>
> >>>>>> Thanks for the suggestion. i've now got a tiny little example that
> >>>>>> compiles on its own that illustrates the problem. Changing the inheritance
> >>>>>> strategy to JOINED makes no difference. Hibernate still does the wrong
> >>>>>> thing.
> >>>>>>
> >>>>>> Best wishes,
> >>>>>>
> >>>>>> --greg
> >>>>>>
> >>>>>>
> >>>>>> On Mon, Jun 22, 2009 at 8:55 AM, Kris Nuttycombe <
> >>>>>> kris.nuttycombe@...> wrote:
> >>>>>>
> >>>>>>> This may be off the mark, but I'm wondering if the reason that you're
> >>>>>>> having difficulty with the parallel inheritance hierarchy problem is
> >>>>>>> not your use of TABLE_PER_CLASS inheritance. In my application, I
> >>>>>>> have
> >>>>>>> a similar construct, but I am using JOINED_TABLE inheritance. This
> >>>>>>> allows for a normal foreign key relationship to be created in the
> >>>>>>> database between C2_table and the base table for CThing, with the
> >>>>>>> result that Hibernate will generate the query for CThing member as a
> >>>>>>> union. Using table per class inheritance, I would expect Hibernate to
> >>>>>>> need to synthesize an additional dtype field in C2_table along with
> >>>>>>> the key column in order to enforce the uniqueness of the keys to the
> >>>>>>> joined entities, and I don't believe that it does this.
> >>>>>>>
> >>>>>>> I'm not sure how the fact that the code is generated is particularly
> >>>>>>> relevant; surely if it's possible to hand-write a successful
> >>>>>>> solution,
> >>>>>>> then your code generator could be made aware of how to construct a
> >>>>>>> viable solution?
> >>>>>>>
> >>>>>>> Kris
> >>>>>>>
> >>>>>>> On Fri, Jun 19, 2009 at 8:47 PM, Meredith
> >>>>>>> Gregory<lgreg.meredith@...> wrote:
> >>>>>>> > All,
> >>>>>>> >
> >>>>>>> > i had a similar problem and found the source of the issues. Spse
> >>>>>>> you have a
> >>>>>>> > container hierarchy (CTop <- C2) side-by-side with a contained
> >>>>>>> hierarchy
> >>>>>>> > (CThing <- CThing1). The inheritance at the top of the container
> >>>>>>> hierarchy,
> >>>>>>> > CTop, causes hibernate to bail on tracking the relations and punt
> >>>>>>> to
> >>>>>>> > embedded values instead. Rewriting the top to be a
> >>>>>>> @MappedSuperClass fixes
> >>>>>>> > the problem in this specific case. However, if your hierarchy is
> >>>>>>> deep,
> >>>>>>> > you're screwed.
> >>>>>>> >
> >>>>>>> > If anybody has a suggestion for a workaround, i'm all ears. The
> >>>>>>> problem is
> >>>>>>> > that it would appear that both Mr Crowley and i are generating Java
> >>>>>>> + JPA
> >>>>>>> > code. So, the solution needs to be algorithmic and not 1-off.
> >>>>>>> >
> >>>>>>> > Perhaps the best solution is to find an alternative to hibernate as
> >>>>>>> this is
> >>>>>>> > a particularly irritating bug.
> >>>>>>> >
> >>>>>>> > Best wishes,
> >>>>>>> >
> >>>>>>> > --greg
> >>>>>>> >
> >>>>>>> > @Entity
> >>>>>>> > @Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
> >>>>>>> > abstract class CTop {
> >>>>>>> >    ...
> >>>>>>> >    @Id
> >>>>>>> >     @GeneratedValue(generator = "system-uuid")
> >>>>>>> >     @GenericGenerator(name = "system-uuid", strategy = "uuid")
> >>>>>>> >     private String id_CTop;
> >>>>>>> > }
> >>>>>>> >
> >>>>>>> > @Entity
> >>>>>>> > @Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
> >>>>>>> > abstract class CThing {
> >>>>>>> >    ...
> >>>>>>> >    @Id
> >>>>>>> >     @GeneratedValue(generator = "system-uuid")
> >>>>>>> >     @GenericGenerator(name = "system-uuid", strategy = "uuid")
> >>>>>>> >     private String id_CThing;
> >>>>>>> > }
> >>>>>>> >
> >>>>>>> > @Entity
> >>>>>>> > @Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
> >>>>>>> > @Table(name = "C2_table", catalog = "mydb_production",
> >>>>>>> uniqueConstraints = {
> >>>>>>> > @UniqueConstraint(columnNames = "uuid") })
> >>>>>>> > class C2 extends CTop {
> >>>>>>> >    CThing thing;
> >>>>>>> > ...
> >>>>>>> >   @OneToOne
> >>>>>>> >     @JoinColumn
> >>>>>>> >     public CThing getThing() {
> >>>>>>> >         return this.thing;
> >>>>>>> >     }
> >>>>>>> >     public void setThing( CThing thing ) {
> >>>>>>> >         this.thing = thing;
> >>>>>>> >     }
> >>>>>>> >
> >>>>>>> > @Column(name = "uuid", unique = false, nullable = true, insertable
> >>>>>>> = true,
> >>>>>>> > updatable = true)
> >>>>>>> >     public String getUuid() {
> >>>>>>> >         return this.uuid;
> >>>>>>> >     }
> >>>>>>> >
> >>>>>>> >     public void setUuid(String uuid) {
> >>>>>>> >         this.uuid = uuid;
> >>>>>>> >     }
> >>>>>>> >
> >>>>>>> >     @Id
> >>>>>>> >     @GeneratedValue(generator = "system-uuid")
> >>>>>>> >     @GenericGenerator(name = "system-uuid", strategy = "uuid")
> >>>>>>> >     @Column(name = "id", unique = false, nullable = true,
> >>>>>>> insertable = true,
> >>>>>>> > updatable = true)
> >>>>>>> >     public String getId() {
> >>>>>>> >         return this.id;
> >>>>>>> >     }
> >>>>>>> >
> >>>>>>> > }
> >>>>>>> >
> >>>>>>> > @Entity
> >>>>>>> > @Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
> >>>>>>> > @Table(name = "CThing1_table", catalog = "mydb_production",
> >>>>>>> > uniqueConstraints = { @UniqueConstraint(columnNames = "uuid") })
> >>>>>>> > class CThing1 extends CThing {
> >>>>>>> > ...
> >>>>>>> >   // lots of ground type fields
> >>>>>>> >
> >>>>>>> > @Column(name = "uuid", unique = false, nullable = true, insertable
> >>>>>>> = true,
> >>>>>>> > updatable = true)
> >>>>>>> >     public String getUuid() {
> >>>>>>> >         return this.uuid;
> >>>>>>> >     }
> >>>>>>> >
> >>>>>>> >     public void setUuid(String uuid) {
> >>>>>>> >         this.uuid = uuid;
> >>>>>>> >     }
> >>>>>>> >
> >>>>>>> >     @Id
> >>>>>>> >     @GeneratedValue(generator = "system-uuid")
> >>>>>>> >     @GenericGenerator(name = "system-uuid", strategy = "uuid")
> >>>>>>> >     @Column(name = "id", unique = false, nullable = true,
> >>>>>>> insertable = true,
> >>>>>>> > updatable = true)
> >>>>>>> >     public String getId() {
> >>>>>>> >         return this.id;
> >>>>>>> >     }
> >>>>>>> >
> >>>>>>> > }
> >>>>>>> >
> >>>>>>> >
> >>>>>>> > On Tue, Jun 16, 2009 at 1:45 PM, Derek Chen-Becker <
> >>>>>>> java@...>
> >>>>>>> > wrote:
> >>>>>>> >>
> >>>>>>> >> John Nilsson wrote:
> >>>>>>> >> > Hi,
> >>>>>>> >> >
> >>>>>>> >> > I think the showSql property has been deprecated in favor of
> >>>>>>> log4j
> >>>>>>> >> > loggers.
> >>>>>>> >> >
> >>>>>>> >> > If you set the log4j level to TRACE for org.hibernate you'll get
> >>>>>>> >> > everything Hibernate has to say about what it is doing. Can't
> >>>>>>> remember
> >>>>>>> >> > which one it is, but I know one of the loggers will give you the
> >>>>>>> >> > values used in queries at the TRACE level.
> >>>>>>> >>
> >>>>>>> >> Good to know. Thanks!
> >>>>>>> >>
> >>>>>>> >
> >>>>>>> >
> >>>>>>> >
> >>>>>>> > --
> >>>>>>> > L.G. Meredith
> >>>>>>> > Managing Partner
> >>>>>>> > Biosimilarity LLC
> >>>>>>> > 1219 NW 83rd St
> >>>>>>> > Seattle, WA 98117
> >>>>>>> >
> >>>>>>> > +1 206.650.3740
> >>>>>>> >
> >>>>>>> > http://biosimilarity.blogspot.com
> >>>>>>> >
> >>>>>>>
> >>>>>>
> >>>>>>
> >>>>>>
> >>>>>> --
> >>>>>> L.G. Meredith
> >>>>>> Managing Partner
> >>>>>> Biosimilarity LLC
> >>>>>> 1219 NW 83rd St
> >>>>>> Seattle, WA 98117
> >>>>>>
> >>>>>> +1 206.650.3740
> >>>>>>
> >>>>>> http://biosimilarity.blogspot.com
> >>>>>>
> >>>>>
> >>>>>
> >>>>>
> >>>>> --
> >>>>> L.G. Meredith
> >>>>> Managing Partner
> >>>>> Biosimilarity LLC
> >>>>> 1219 NW 83rd St
> >>>>> Seattle, WA 98117
> >>>>>
> >>>>> +1 206.650.3740
> >>>>>
> >>>>> http://biosimilarity.blogspot.com
> >>>>>
> >>>>>
> >>>>>
> >>>>
> >>>>
> >>>>
> >>>
> >>>
> >>> --
> >>> L.G. Meredith
> >>> Managing Partner
> >>> Biosimilarity LLC
> >>> 1219 NW 83rd St
> >>> Seattle, WA 98117
> >>>
> >>> +1 206.650.3740
> >>>
> >>> http://biosimilarity.blogspot.com
> >>>
> >>>
> >>>
> >>
> >
> > --~--~---------~--~----~------------~-------~--~----~
> > You received this message because you are subscribed to the Google Groups
> > "Lift" group.
> > To post to this group, send email to liftweb@...
> > To unsubscribe from this group, send email to
> > liftweb+unsubscribe@...<liftweb%2Bunsubscribe@...>
> > For more options, visit this group at
> > http://groups.google.com/group/liftweb?hl=en
> > -~----------~----~----~----~------~----~------~--~---
> >
> >
>
>
> --
> L.G. Meredith
> Managing Partner
> Biosimilarity LLC
> 1219 NW 83rd St
> Seattle, WA 98117
>
> +1 206.650.3740
>
> http://biosimilarity.blogspot.com

--
+---------------------------------------------------------------+
| Derek Chen-Becker                                             |
| http://chen-becker.org                                        |
|                                                               |
| PGP key available on request or from public key servers       |
| Fngrprnt: 209A 77CA A4F9 E716 E20C  6348 B657 77EC 21A7 FB53  |
+---------------------------------------------------------------+