-->
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: hibernate project
PostPosted: Mon Jan 16, 2006 10:47 pm 
Beginner
Beginner

Joined: Mon Dec 05, 2005 2:59 am
Posts: 31
my project concept is to create the databases which have table "user" and "service". each user can require for many services.how to make related? the hbm file is shown as below:

user.hbm.xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">

<hibernate-mapping
>
<class
name="model.User"
table="USER"
>

<id
name="empNo"
column="EMP_NO"
type="java.lang.String"
>
<generator class="assigned">
<!--
To add non XDoclet generator parameters, create a file named
hibernate-generator-params-User.xml
containing the additional parameters and place it in your merge dir.
-->
</generator>
</id>

<property
name="firstName"
type="string"
update="true"
insert="true"
>
<column
name="FIRST_NAME"
/>
</property>

<property
name="lastName"
type="string"
update="true"
insert="true"
>
<column
name="LAST_NAME"
/>
</property>

<property
name="company"
type="string"
update="true"
insert="true"
>
<column
name="COMPANY"
/>
</property>

<property
name="department"
type="string"
update="true"
insert="true"
>
<column
name="DEPARTMENT"
/>
</property>

<property
name="designation"
type="string"
update="true"
insert="true"
>
<column
name="DESIGNATION"
/>
</property>

<property
name="extNo"
type="string"
update="true"
insert="true"
>
<column
name="EXT_NO"
/>
</property>

<list
name="userInfo"
lazy="false"
inverse="true"
cascade="none"
>

<key
column="EMP_NO"
>
</key>

<index
column="NO"
type="integer"
/>

<one-to-many
class="model.Service"
/>

</list>


<!--
To add non XDoclet property mappings, create a file named
hibernate-properties-User.xml
containing the additional properties and place it in your merge dir.
-->

</class>

</hibernate-mapping>


service.hbm.xml


<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">

<hibernate-mapping
>
<class
name="model.Service"
table="SERVICE"
>

<id
name="serviceId"
column="SERVICE_ID"
type="java.lang.String"
>
<generator class="assigned">
<!--
To add non XDoclet generator parameters, create a file named
hibernate-generator-params-User.xml
containing the additional parameters and place it in your merge dir.
-->
</generator>
</id>

<property
name="requireDate"
type="Date"
update="true"
insert="true"
>
<column
name="REQUIRE_DATE"
/>
</property>

<property
name="issueDate"
type="Date"
update="true"
insert="true"
>
<column
name="ISSUE_DATE"
/>
</property>

<many-to-one
name="empNo"
class="model.User"
cascade="none"
lazy="false"
update="true"
insert="true"
foreign-key="FK1_EMP_NO"
column=""
not-null="true"
/>

<property
name="state"
type="int"
update="true"
insert="true"
>
<column
name="STATE"
/>
</property>

<property
name="serviceRemark"
type="string"
update="true"
insert="true"
>
<column
name="SERVICE_REMARK"
/>
</property>

<property
name="service"
type="string"
update="true"
insert="true"
>
<column
name="SERVICE"
/>
</property>

<!--
To add non XDoclet property mappings, create a file named
hibernate-properties-User.xml
containing the additional properties and place it in your merge dir.
-->

</class>

</hibernate-mapping>


can anyone comment on my script??


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jan 17, 2006 4:02 am 
Regular
Regular

Joined: Tue Jan 03, 2006 9:52 am
Posts: 52
Location: Zurich
Use another generator method, example "native" instead of "assigned".

Urs


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jan 17, 2006 9:59 pm 
Beginner
Beginner

Joined: Mon Dec 05, 2005 2:59 am
Posts: 31
when i try to connect in hibernator, the error states that "unknown database symis'. what happened??

i'm using org.hibernate.dialect.MySql but i can''t change dialect 'net.sf.hibernate.dialect.MySql' to 'org.hibernate.dialect.MySql'. anyone can help???


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jan 18, 2006 8:03 am 
Regular
Regular

Joined: Tue Jan 03, 2006 9:52 am
Posts: 52
Location: Zurich
Maybe you can post your hibernate.cfg.xml file here.
Which hibernate version do you use?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jan 18, 2006 8:05 pm 
Beginner
Beginner

Joined: Mon Dec 05, 2005 2:59 am
Posts: 31
i have this 'mysql-mis-ds.xml' in the deploy folder of jboss directory. the coding is as shown below:

<?xml version="1.0" encoding="UTF-8"?>

<!-- ===================================================================== -->
<!-- -->
<!-- JBoss Server Configuration -->
<!-- -->
<!-- ===================================================================== -->

<!-- $Id: mysql-ds.xml,v 1.1 2002/07/22 22:57:24 d_jencks Exp $ -->
<!-- ==================================================================== -->
<!-- Datasource config for MySQL using 2.0.11 driver -->
<!-- ==================================================================== -->
<!--?profileSql=true-->

<datasources>

<local-tx-datasource>
<jndi-name>MySqlDSMIS</jndi-name>
<connection-url>jdbc:mysql://127.0.0.1:3306/symis?profileSql=true&amp;useUnicode=true&amp;characterEncoding=UTF8
</connection-url>
<driver-class>com.mysql.jdbc.Driver</driver-class>
<user-name>user</user-name>
<password>123</password>
</local-tx-datasource>

</datasources>


the error now is access of the user to database 'symis' is denied. i think i can't even map into database. so anyone can help??


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.