hibernate XML file

G

gk

<hibernate-mapping>

<class name="Event" table="EVENTS">
<id name="id" column="EVENT_ID"> // type is missing !!
<generator class="increment"/>
</id>
<property name="date" type="timestamp" column="EVENT_DATE"/> //
type is present
<property name="title"/>// type is missing !!
</class>

</hibernate-mapping>


It is a matter of concen sometimes type is missing and sometimes type
is there .


is it not essential ?

so, when should i skip "type" and when i should Not skip "type" ?
 
G

gk

i could not understand your comment.
i asked when do i use "type" and when i dont .

if i use "type" should it be java type or SQL type ?
 
A

Andrew Thompson

Andrew said:
gk wrote:
....

Since it generates HTML,

...or rather *XML* (which I might have noticed from
the subject line if I had been paying attention!)
..your best bet is to ask the validator.
<http://validator.w3.org/>

Err... there are XML validators*, but the question then is,
...what are you going to validate you XML against?
Does it have a DTD?

* <http://www.w3.org/2001/03/webdata/xsv>

My quick search on..
<http://www.google.com.au/search?q=hibernate+xml+dtd>
...led me here, ..
<http://www.hibernate.org/211.html>, but I'll leave
it to you to chase down those answers.

HTH
 
A

Andrew Thompson

gk said:
i could not understand your comment.

That's because it was a dumb comment for me to
make, that had no relevance to your problem. ;-)
See my other (slightly) smarter post.
 
B

Bryce

<hibernate-mapping>

<class name="Event" table="EVENTS">
<id name="id" column="EVENT_ID"> // type is missing !!
<generator class="increment"/>
</id>
<property name="date" type="timestamp" column="EVENT_DATE"/> //
type is present
<property name="title"/>// type is missing !!
</class>

</hibernate-mapping>


It is a matter of concen sometimes type is missing and sometimes type
is there .


is it not essential ?

so, when should i skip "type" and when i should Not skip "type" ?

I believe if you don't specify type, it will do its best to try to
determine the type.

And the type can be either a Java class or a Hibernate type.

From:
http://www.hibernate.org/hib_docs/v3/reference/en/html/mapping.html#mapping-declaration-property

"typename could be:

1. The name of a Hibernate basic type (eg. integer, string,
character, date, timestamp, float, binary, serializable, object,
blob).

2. The name of a Java class with a default basic type (eg. int,
float, char, java.lang.String, java.util.Date, java.lang.Integer,
java.sql.Clob).

3. The name of a serializable Java class.

4. The class name of a custom type (eg.
com.illflow.type.MyCustomType).


If you do not specify a type, Hibernate will use reflection upon the
named property to take a guess at the correct Hibernate type. "
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,430
Messages
2,571,676
Members
48,796
Latest member
Greg L.

Latest Threads

Top