Master-Detail example Using Tapestry-hibernate

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Master-Detail example Using Tapestry-hibernate

abangkis
Hi guys,

is there any example of creating a Master-Detail table using Tapestry-hibernate.

I've tried create two entity clas :

@Entity
public class TaskItem {

       
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @NonVisual
    private Long id;

    private User user;

        public Long getId() {
                return id;
        }

       
    @ManyToOne(targetEntity=User.class)
    @JoinColumn(name="USER_ID")
        public User getUser() {
                return user;
        }
}


and

@Entity
public class User {

        public enum AccessLevel {
                User, Admin, DataEntry
        }
       
        @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @NonVisual
        private Long id;
       
        private String username;
       
        private String password;


        public Long getId() {
                return id;
        }

        public String getUsername() {
                return username;
        }

        public String getPassword() {
                return password;
        }
}

Its pretty basic stuff, but i've got an error :

org.hibernate.MappingException
Could not determine type for: com.cie2.tip.entities.User, at table:
TaskItem, for columns: [org.hibernate.mapping.Column(user)]

I think there's no problem with the .tml file. Since if i change the
user variable type into Integer, the data will be inserted to the
database.

Can anyone help ?

Cheers,

Abangkis

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Master-Detail example Using Tapestry-hibernate

Thiago H de Paula Figueiredo
Em Sat, 15 Nov 2008 07:47:53 -0300, abangkis <[hidden email]> escreveu:

> @Entity
> public class TaskItem {
>     @Id
>     @GeneratedValue(strategy = GenerationType.IDENTITY)
>     @NonVisual
>     private Long id;
>     private User user;
> public Long getId() {
> return id;
> }
>     @ManyToOne(targetEntity=User.class)
>     @JoinColumn(name="USER_ID")
> public User getUser() {
> return user;
> }
> }

Your problem is not related to Tapestry, just to Hibernate.

You must choose: you put the mapping annotations in the fields (x)or your  
put the annotations in the getters. You cannot mix them. I suggest you to  
always put them in the getters. By the way, you don't need to use the  
targetEntity field of @ManyToOne in your example.

--
Thiago H. de Paula Figueiredo
Independent Java consultant, developer, and instructor
http://www.arsmachina.com.br/thiago

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Master-Detail example Using Tapestry-hibernate

abangkis
Thanks a lot for your help.

Yes, I only put that as a last resort. Because any other way that i
tried didn't work.

Cheers,

Abangkis

On Sat, Nov 15, 2008 at 7:50 PM, Thiago H. de Paula Figueiredo
<[hidden email]> wrote:

> Em Sat, 15 Nov 2008 07:47:53 -0300, abangkis <[hidden email]> escreveu:
>
>> @Entity
>> public class TaskItem {
>>    @Id
>>    @GeneratedValue(strategy = GenerationType.IDENTITY)
>>    @NonVisual
>>    private Long id;
>>    private User user;
>>        public Long getId() {
>>                return id;
>>        }
>>    @ManyToOne(targetEntity=User.class)
>>    @JoinColumn(name="USER_ID")
>>        public User getUser() {
>>                return user;
>>        }
>> }
>
> Your problem is not related to Tapestry, just to Hibernate.
>
> You must choose: you put the mapping annotations in the fields (x)or your
> put the annotations in the getters. You cannot mix them. I suggest you to
> always put them in the getters. By the way, you don't need to use the
> targetEntity field of @ManyToOne in your example.
>
> --
> Thiago H. de Paula Figueiredo
> Independent Java consultant, developer, and instructor
> http://www.arsmachina.com.br/thiago
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Master-Detail example Using Tapestry-hibernate

Ronny L
In reply to this post by abangkis
You can have a look at Tapestry jumpstart for integration between Tapestry-hibernate

Ronny

abangkis wrote
Hi guys,

is there any example of creating a Master-Detail table using Tapestry-hibernate.

I've tried create two entity clas :

@Entity
public class TaskItem {

       
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @NonVisual
    private Long id;

    private User user;

        public Long getId() {
                return id;
        }

       
    @ManyToOne(targetEntity=User.class)
    @JoinColumn(name="USER_ID")
        public User getUser() {
                return user;
        }
}


and

@Entity
public class User {

        public enum AccessLevel {
                User, Admin, DataEntry
        }
       
        @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @NonVisual
        private Long id;
       
        private String username;
       
        private String password;


        public Long getId() {
                return id;
        }

        public String getUsername() {
                return username;
        }

        public String getPassword() {
                return password;
        }
}

Its pretty basic stuff, but i've got an error :

org.hibernate.MappingException
Could not determine type for: com.cie2.tip.entities.User, at table:
TaskItem, for columns: [org.hibernate.mapping.Column(user)]

I think there's no problem with the .tml file. Since if i change the
user variable type into Integer, the data will be inserted to the
database.

Can anyone help ?

Cheers,

Abangkis

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org