« Return to Thread: [scala] JPA question

[scala] JPA question

by Balthazar Crowley :: Rate this Message:

Reply to Author | View in Thread

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

 « Return to Thread: [scala] JPA question