You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Olivier <ta...@jax.be> on 2007/10/12 17:50:06 UTC

T5: Tapestry, Hibernate and Underscores.

Hi,


I followed the small tutorial on using hibernate with T5 here
http://wiki.apache.org/tapestry/Tapestry5HowToUseTapestryHibernate and it
worked like a charm. Thank you to whoever wrote this!

The example uses underscores for some private fields and sometimes not. Now
I want to use this in my entities but then Hibernate generates incorrect
column names. Isn't there a way for tuning this in the configuration file
or something? If someone has that info, please share it with me!


Thank you in advance,
Olivier



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


Re: T5: Tapestry, Hibernate and Underscores.

Posted by Christian Gruber <ch...@gmail.com>.
I did not.  The problem was not with hibernate.  The problem was that  
you used hibernate annotations (JPA annotations, actually) in a way  
other than their documented intent.  If you annotate a field _foo,  
then the property name will be _foo according to hibernate, regardless  
of accessors.  You can override the automatic column designation with  
@Column but by default, it'll look for a column named _foo.  You can  
also solve it by either annotating the getter (as mentioned  
elsewhere), or by renaming your variable to not use the _.  Where am I  
misunderstanding?  My comments about tapestry were only that you could  
avoid using _foo style and tapestry would continue to work.

Anyway, this is a hibernate configuration question, not a tapestry  
question, so we should kill this thread on this list anyway.

Christian.

On 15-Oct-07, at 2:29 AM, Davor Hrg wrote:

> maybe you missed the point here,
>
> never mind the reason I use the _ prefix ......
> the problem was with hibernate, not with tapestry....
>
> Davor Hrg
>
> On 10/15/07, Christian Gruber <ch...@gmail.com> wrote:
>>
>> Tapestry doesn't require _ prefixes, mind you.  That's a Howard M.
>> Lewis Ship-ism.  (actually, I have it too from my NeXTSTEP days.)
>> It's not mandatory, however, so on your persistent objects, you could
>> use the typical pattern and annotate your properties, if that's how
>> you want to do it.  Tapestry will (it seems) do its magic on
>> properties taht are annotated regardless of their prefix, because  
>> it's
>> the annotation that matters, not the variable name.
>>
>> Christian.
>>
>> On 14-Oct-07, at 4:17 PM, Davor Hrg wrote:
>>
>>> hi,
>>>
>>> I've tried to adopt underscores for private fields,
>>> so the the tutorial got mixed when I've created that page with
>>> AngeloChen.
>>>
>>> I'll check tomorow if this is true, but I belive you
>>> can avoid this problem by not putting annotations
>>> on the fields and putting them on the getters or setters instead
>>>
>>> @Id
>>> private long _id;
>>>
>>> public getId()...
>>> public setId()...
>>>
>>> in this example hibernate will see annotation on the field
>>> and see it as _id
>>>
>>> if you change the code to
>>>
>>> private long _id;
>>>
>>> @Id
>>> public getId()...
>>> public setId()...
>>>
>>> in this example hibernate will see annotation on the getter
>>> and see it as id when "get" is stripped
>>>
>>> !Beware. if you put annotations both on fields and getters
>>> hibernate will loose some of them
>>>
>>>
>>> I'll find some time and fix the code to adopt one convention
>>>
>>> Davor Hrg
>>>
>>>
>>>
>>>
>>>
>>>
>>> On 10/13/07, Angelo Chen <an...@yahoo.com.hk> wrote:
>>>>
>>>>
>>>> Hi Olivier,
>>>>
>>>> In that tutorial the only place with underscore is _session, the
>>>> entities
>>>> for hibernate do not have underscore, I prefer this way, it looks
>>>> normal
>>>> when u do some sql/hql queries, but for Tapestry variables ,seems
>>>> to me, a
>>>> unspoken rule here is to prefix underscore.
>>>>
>>>> A.C.
>>>>
>>>>
>>>> Olivier-36 wrote:
>>>>>
>>>>>
>>>>> Hi,
>>>>>
>>>>>
>>>>> I followed the small tutorial on using hibernate with T5 here
>>>>> http://wiki.apache.org/tapestry/Tapestry5HowToUseTapestryHibernate
>>>>> and
>>>> it
>>>>> worked like a charm. Thank you to whoever wrote this!
>>>>>
>>>>> The example uses underscores for some private fields and sometimes
>>>>> not.
>>>>> Now
>>>>> I want to use this in my entities but then Hibernate generates
>>>>> incorrect
>>>>> column names. Isn't there a way for tuning this in the  
>>>>> configuration
>>>> file
>>>>> or something? If someone has that info, please share it with me!
>>>>>
>>>>>
>>>>> Thank you in advance,
>>>>> Olivier
>>>>>
>>>>>
>>>>>
>>>>> ---------------------------------------------------------------------
>>>>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>>>>> For additional commands, e-mail: users-help@tapestry.apache.org
>>>>>
>>>>>
>>>>>
>>>>
>>>> --
>>>> View this message in context:
>>>>
>> http://www.nabble.com/T5%3A-Tapestry%2C-Hibernate-and-Underscores.-tf4614534.html#a13188869
>>>> Sent from the Tapestry - User mailing list archive at Nabble.com.
>>>>
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>>>> For additional commands, e-mail: users-help@tapestry.apache.org
>>>>
>>>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>> For additional commands, e-mail: users-help@tapestry.apache.org
>>
>>


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


Re: T5: Tapestry, Hibernate and Underscores.

Posted by Davor Hrg <hr...@gmail.com>.
maybe you missed the point here,

never mind the reason I use the _ prefix ......
the problem was with hibernate, not with tapestry....

Davor Hrg

On 10/15/07, Christian Gruber <ch...@gmail.com> wrote:
>
> Tapestry doesn't require _ prefixes, mind you.  That's a Howard M.
> Lewis Ship-ism.  (actually, I have it too from my NeXTSTEP days.)
> It's not mandatory, however, so on your persistent objects, you could
> use the typical pattern and annotate your properties, if that's how
> you want to do it.  Tapestry will (it seems) do its magic on
> properties taht are annotated regardless of their prefix, because it's
> the annotation that matters, not the variable name.
>
> Christian.
>
> On 14-Oct-07, at 4:17 PM, Davor Hrg wrote:
>
> > hi,
> >
> > I've tried to adopt underscores for private fields,
> > so the the tutorial got mixed when I've created that page with
> > AngeloChen.
> >
> > I'll check tomorow if this is true, but I belive you
> > can avoid this problem by not putting annotations
> > on the fields and putting them on the getters or setters instead
> >
> > @Id
> > private long _id;
> >
> > public getId()...
> > public setId()...
> >
> > in this example hibernate will see annotation on the field
> > and see it as _id
> >
> > if you change the code to
> >
> > private long _id;
> >
> > @Id
> > public getId()...
> > public setId()...
> >
> > in this example hibernate will see annotation on the getter
> > and see it as id when "get" is stripped
> >
> > !Beware. if you put annotations both on fields and getters
> > hibernate will loose some of them
> >
> >
> > I'll find some time and fix the code to adopt one convention
> >
> > Davor Hrg
> >
> >
> >
> >
> >
> >
> > On 10/13/07, Angelo Chen <an...@yahoo.com.hk> wrote:
> >>
> >>
> >> Hi Olivier,
> >>
> >> In that tutorial the only place with underscore is _session, the
> >> entities
> >> for hibernate do not have underscore, I prefer this way, it looks
> >> normal
> >> when u do some sql/hql queries, but for Tapestry variables ,seems
> >> to me, a
> >> unspoken rule here is to prefix underscore.
> >>
> >> A.C.
> >>
> >>
> >> Olivier-36 wrote:
> >>>
> >>>
> >>> Hi,
> >>>
> >>>
> >>> I followed the small tutorial on using hibernate with T5 here
> >>> http://wiki.apache.org/tapestry/Tapestry5HowToUseTapestryHibernate
> >>> and
> >> it
> >>> worked like a charm. Thank you to whoever wrote this!
> >>>
> >>> The example uses underscores for some private fields and sometimes
> >>> not.
> >>> Now
> >>> I want to use this in my entities but then Hibernate generates
> >>> incorrect
> >>> column names. Isn't there a way for tuning this in the configuration
> >> file
> >>> or something? If someone has that info, please share it with me!
> >>>
> >>>
> >>> Thank you in advance,
> >>> Olivier
> >>>
> >>>
> >>>
> >>> ---------------------------------------------------------------------
> >>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> >>> For additional commands, e-mail: users-help@tapestry.apache.org
> >>>
> >>>
> >>>
> >>
> >> --
> >> View this message in context:
> >>
> http://www.nabble.com/T5%3A-Tapestry%2C-Hibernate-and-Underscores.-tf4614534.html#a13188869
> >> Sent from the Tapestry - User mailing list archive at Nabble.com.
> >>
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> >> For additional commands, e-mail: users-help@tapestry.apache.org
> >>
> >>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>

Re: T5: Tapestry, Hibernate and Underscores.

Posted by Christian Gruber <ch...@gmail.com>.
Tapestry doesn't require _ prefixes, mind you.  That's a Howard M.  
Lewis Ship-ism.  (actually, I have it too from my NeXTSTEP days.)   
It's not mandatory, however, so on your persistent objects, you could  
use the typical pattern and annotate your properties, if that's how  
you want to do it.  Tapestry will (it seems) do its magic on  
properties taht are annotated regardless of their prefix, because it's  
the annotation that matters, not the variable name.

Christian.

On 14-Oct-07, at 4:17 PM, Davor Hrg wrote:

> hi,
>
> I've tried to adopt underscores for private fields,
> so the the tutorial got mixed when I've created that page with  
> AngeloChen.
>
> I'll check tomorow if this is true, but I belive you
> can avoid this problem by not putting annotations
> on the fields and putting them on the getters or setters instead
>
> @Id
> private long _id;
>
> public getId()...
> public setId()...
>
> in this example hibernate will see annotation on the field
> and see it as _id
>
> if you change the code to
>
> private long _id;
>
> @Id
> public getId()...
> public setId()...
>
> in this example hibernate will see annotation on the getter
> and see it as id when "get" is stripped
>
> !Beware. if you put annotations both on fields and getters
> hibernate will loose some of them
>
>
> I'll find some time and fix the code to adopt one convention
>
> Davor Hrg
>
>
>
>
>
>
> On 10/13/07, Angelo Chen <an...@yahoo.com.hk> wrote:
>>
>>
>> Hi Olivier,
>>
>> In that tutorial the only place with underscore is _session, the  
>> entities
>> for hibernate do not have underscore, I prefer this way, it looks  
>> normal
>> when u do some sql/hql queries, but for Tapestry variables ,seems  
>> to me, a
>> unspoken rule here is to prefix underscore.
>>
>> A.C.
>>
>>
>> Olivier-36 wrote:
>>>
>>>
>>> Hi,
>>>
>>>
>>> I followed the small tutorial on using hibernate with T5 here
>>> http://wiki.apache.org/tapestry/Tapestry5HowToUseTapestryHibernate  
>>> and
>> it
>>> worked like a charm. Thank you to whoever wrote this!
>>>
>>> The example uses underscores for some private fields and sometimes  
>>> not.
>>> Now
>>> I want to use this in my entities but then Hibernate generates  
>>> incorrect
>>> column names. Isn't there a way for tuning this in the configuration
>> file
>>> or something? If someone has that info, please share it with me!
>>>
>>>
>>> Thank you in advance,
>>> Olivier
>>>
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>>> For additional commands, e-mail: users-help@tapestry.apache.org
>>>
>>>
>>>
>>
>> --
>> View this message in context:
>> http://www.nabble.com/T5%3A-Tapestry%2C-Hibernate-and-Underscores.-tf4614534.html#a13188869
>> Sent from the Tapestry - User mailing list archive at Nabble.com.
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>> For additional commands, e-mail: users-help@tapestry.apache.org
>>
>>


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


Re: T5: Tapestry, Hibernate and Underscores.

Posted by Davor Hrg <hr...@gmail.com>.
hi,

I've tried to adopt underscores for private fields,
so the the tutorial got mixed when I've created that page with AngeloChen.

I'll check tomorow if this is true, but I belive you
can avoid this problem by not putting annotations
on the fields and putting them on the getters or setters instead

@Id
private long _id;

public getId()...
public setId()...

in this example hibernate will see annotation on the field
and see it as _id

if you change the code to

private long _id;

@Id
public getId()...
public setId()...

in this example hibernate will see annotation on the getter
and see it as id when "get" is stripped

!Beware. if you put annotations both on fields and getters
hibernate will loose some of them


I'll find some time and fix the code to adopt one convention

Davor Hrg






On 10/13/07, Angelo Chen <an...@yahoo.com.hk> wrote:
>
>
> Hi Olivier,
>
> In that tutorial the only place with underscore is _session, the entities
> for hibernate do not have underscore, I prefer this way, it looks normal
> when u do some sql/hql queries, but for Tapestry variables ,seems to me, a
> unspoken rule here is to prefix underscore.
>
> A.C.
>
>
> Olivier-36 wrote:
> >
> >
> > Hi,
> >
> >
> > I followed the small tutorial on using hibernate with T5 here
> > http://wiki.apache.org/tapestry/Tapestry5HowToUseTapestryHibernate and
> it
> > worked like a charm. Thank you to whoever wrote this!
> >
> > The example uses underscores for some private fields and sometimes not.
> > Now
> > I want to use this in my entities but then Hibernate generates incorrect
> > column names. Isn't there a way for tuning this in the configuration
> file
> > or something? If someone has that info, please share it with me!
> >
> >
> > Thank you in advance,
> > Olivier
> >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> > For additional commands, e-mail: users-help@tapestry.apache.org
> >
> >
> >
>
> --
> View this message in context:
> http://www.nabble.com/T5%3A-Tapestry%2C-Hibernate-and-Underscores.-tf4614534.html#a13188869
> Sent from the Tapestry - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>

Re: T5: Tapestry, Hibernate and Underscores.

Posted by Angelo Chen <an...@yahoo.com.hk>.
Hi Olivier,

In that tutorial the only place with underscore is _session, the entities
for hibernate do not have underscore, I prefer this way, it looks normal
when u do some sql/hql queries, but for Tapestry variables ,seems to me, a
unspoken rule here is to prefix underscore.

A.C.


Olivier-36 wrote:
> 
> 
> Hi,
> 
> 
> I followed the small tutorial on using hibernate with T5 here
> http://wiki.apache.org/tapestry/Tapestry5HowToUseTapestryHibernate and it
> worked like a charm. Thank you to whoever wrote this!
> 
> The example uses underscores for some private fields and sometimes not.
> Now
> I want to use this in my entities but then Hibernate generates incorrect
> column names. Isn't there a way for tuning this in the configuration file
> or something? If someone has that info, please share it with me!
> 
> 
> Thank you in advance,
> Olivier
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/T5%3A-Tapestry%2C-Hibernate-and-Underscores.-tf4614534.html#a13188869
Sent from the Tapestry - User mailing list archive at Nabble.com.


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


Re: T5: Tapestry, Hibernate and Underscores.

Posted by lasitha <la...@gmail.com>.
Hi oliver,  hibernate is pretty well documented... :)
http://www.hibernate.org/hib_docs/v3/reference/en/html/session-configuration.html#configuration-namingstrategy
Cheers, lasitha.

On 10/13/07, Olivier <ta...@jax.be> wrote:
>
> But that would mean I have to map each and every column. I was actually
> looking for a way to tell hibernate: "Hey, all my class properties are
> prefixed with an underscore but my db columns are not.". Is something like
> that possible?
>
> On Fri, 12 Oct 2007 09:51:20 -0700, "Josh Canfield" <jo...@thedailytube.com>
> wrote:
> > You can explicitly tell hibernate the names of your columns using
> hibernate
> > annotations or your hibernate mapping files. You'll need to check with
> the
> > hibernate docs/lists for more details.
> >
> > Josh
> >
> >
> > On 10/12/07, Olivier <ta...@jax.be> wrote:
> >>
> >>
> >> Hi,
> >>
> >>
> >> I followed the small tutorial on using hibernate with T5 here
> >> http://wiki.apache.org/tapestry/Tapestry5HowToUseTapestryHibernate and
> > it
> >> worked like a charm. Thank you to whoever wrote this!
> >>
> >> The example uses underscores for some private fields and sometimes not.
> >> Now
> >> I want to use this in my entities but then Hibernate generates incorrect
> >> column names. Isn't there a way for tuning this in the configuration
> > file
> >> or something? If someone has that info, please share it with me!
> >>
> >>
> >> Thank you in advance,
> >> Olivier
> >>
> >>
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> >> For additional commands, e-mail: users-help@tapestry.apache.org
> >>
> >>
> >
> >
> > --
> > --
> > TheDailyTube.com. Sign up and get the best new videos on the internet
> > delivered fresh to your inbox.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>

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


Re: T5: Tapestry, Hibernate and Underscores.

Posted by Olivier <ta...@jax.be>.
But that would mean I have to map each and every column. I was actually
looking for a way to tell hibernate: "Hey, all my class properties are
prefixed with an underscore but my db columns are not.". Is something like
that possible?

On Fri, 12 Oct 2007 09:51:20 -0700, "Josh Canfield" <jo...@thedailytube.com>
wrote:
> You can explicitly tell hibernate the names of your columns using
hibernate
> annotations or your hibernate mapping files. You'll need to check with
the
> hibernate docs/lists for more details.
> 
> Josh
> 
> 
> On 10/12/07, Olivier <ta...@jax.be> wrote:
>>
>>
>> Hi,
>>
>>
>> I followed the small tutorial on using hibernate with T5 here
>> http://wiki.apache.org/tapestry/Tapestry5HowToUseTapestryHibernate and
> it
>> worked like a charm. Thank you to whoever wrote this!
>>
>> The example uses underscores for some private fields and sometimes not.
>> Now
>> I want to use this in my entities but then Hibernate generates incorrect
>> column names. Isn't there a way for tuning this in the configuration
> file
>> or something? If someone has that info, please share it with me!
>>
>>
>> Thank you in advance,
>> Olivier
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>> For additional commands, e-mail: users-help@tapestry.apache.org
>>
>>
> 
> 
> --
> --
> TheDailyTube.com. Sign up and get the best new videos on the internet
> delivered fresh to your inbox.


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


Re: T5: Tapestry, Hibernate and Underscores.

Posted by Josh Canfield <jo...@thedailytube.com>.
You can explicitly tell hibernate the names of your columns using hibernate
annotations or your hibernate mapping files. You'll need to check with the
hibernate docs/lists for more details.

Josh


On 10/12/07, Olivier <ta...@jax.be> wrote:
>
>
> Hi,
>
>
> I followed the small tutorial on using hibernate with T5 here
> http://wiki.apache.org/tapestry/Tapestry5HowToUseTapestryHibernate and it
> worked like a charm. Thank you to whoever wrote this!
>
> The example uses underscores for some private fields and sometimes not.
> Now
> I want to use this in my entities but then Hibernate generates incorrect
> column names. Isn't there a way for tuning this in the configuration file
> or something? If someone has that info, please share it with me!
>
>
> Thank you in advance,
> Olivier
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>


-- 
--
TheDailyTube.com. Sign up and get the best new videos on the internet
delivered fresh to your inbox.