-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 posts ] 
Author Message
 Post subject: mapping: db creation and varchar length?
PostPosted: Thu Dec 30, 2004 6:32 pm 
Newbie

Joined: Thu Dec 30, 2004 6:19 pm
Posts: 2
Hi,

I am new to hibernate and not a grizzled java developer... please consider if these question are too simple. But I did not find anything which solved my questions:

1) Is it possible to create a mysql db and a db user with hibernate mapping? If yes, has anybody a simple example?

2) With the mapping below, two varchar(255) fields (from_id and to_id) were generated. Here I need to know, what can I change in the mapping, to get: varchar(170) ???

Thanks in advance, and a happy new year... ;-)

regards
chako


Hibernate version: 2.1.7c

Mapping documents:
...

<set name="contactsOf" table="PX_CONTACT" lazy="true" inverse="true" >
<key column="to_id" />
<many-to-many class="org.pixory.pxmodel.PXPerson" column="from_id" />
</set>
...
<set name="contacts" table="PX_CONTACT" cascade="all" lazy="true">
<key column="from_id" />
<many-to-many class="org.pixory.pxmodel.PXIdentity" column="to_id" />
</set>
...


Name and version of the database you are using: MySQL 4.1.7


Top
 Profile  
 
 Post subject: do your HW
PostPosted: Thu Dec 30, 2004 8:25 pm 
Newbie

Joined: Wed Oct 13, 2004 11:23 am
Posts: 14
I don't know if we can create database using hibernate but I do know that while configuring hibernate we have to give db name as well as user name. So, i guess if you can connect as admin/root you can modify admin tables.

For getting desired length varchar -- use param 'length' ... all the details are in reference doc. or book ;-)

Hope it helps.
--Anand


Top
 Profile  
 
 Post subject: Re: mapping: db creation and varchar length?
PostPosted: Thu Dec 30, 2004 8:29 pm 
Contributor
Contributor

Joined: Thu Nov 06, 2003 9:49 pm
Posts: 104
Location: New York, NY
chako wrote:
Hi,
1) Is it possible to create a mysql db and a db user with hibernate mapping? If yes, has anybody a simple example?

2) With the mapping below, two varchar(255) fields (from_id and to_id) were generated. Here I need to know, what can I change in the mapping, to get: varchar(170) ???


1) Creating databases and users is an administrative function in MySQL, and every other DBMS that I know of. Hibernate doesn't handle administrative duties, just schema and data. :)

2) Use the length attribute, it's in the basic docos here on this site.


Top
 Profile  
 
 Post subject: Re: mapping: db creation and varchar length?
PostPosted: Thu Dec 30, 2004 9:11 pm 
Newbie

Joined: Thu Dec 30, 2004 6:19 pm
Posts: 2
jdavis wrote:
2) Use the length attribute, it's in the basic docos here on this site.


Answer 1: Thanks. As I "feared" already... ;-)

Answer 2: I found that attribute but got an error that this attribute is not supported for many to many..., probably wrong syntax (as I told earlier I am not a programmer...)...

Is it possible that you add the length parameter the right way in the source above? That would help me pretty much...

Thanks a lot for the fast answer!!!

tia
Chako


Top
 Profile  
 
 Post subject:
PostPosted: Fri Dec 31, 2004 9:31 am 
Contributor
Contributor

Joined: Thu Nov 06, 2003 9:49 pm
Posts: 104
Location: New York, NY
Quote:
Is it possible that you add the length parameter the right way in the source above? That would help me pretty much...


The answer to your question is in the docs, take a moment ot read them and try again. Take a look at the mapping DTD:

http://hibernate.sourceforge.net/hibern ... ng-2.0.dtd


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.