7M2 hibernate question

Hi,

In 7M2 I created Hibernate facet associated with hibernate.cfg.xml
Something like this:
.... ]]>
Idea can not resolve file MyTables.hbm.xml (it's displayed in red).
Both files are in the same directory (project root).
Did I miss some settings?
In some other posting somebody said that mapping-resource is not fully
supported yet. Will it be in the final version of Idea 7?

Tom

0

Hello Tom,

The mapping file should be under some source root.

Regards,
Gregory Shrago

Tom wrote:

Hi,

In 7M2 I created Hibernate facet associated with hibernate.cfg.xml
Something like this:
<hibernate-configuration>
<session-factory name="MyFactory">
....
<mapping resource="MyTables.hbm.xml"/>
</session-factory>
</hibernate-configuration>
Idea can not resolve file MyTables.hbm.xml (it's displayed in red).
Both files are in the same directory (project root).
Did I miss some settings?
In some other posting somebody said that mapping-resource is not fully
supported yet. Will it be in the final version of Idea 7?

Tom

0

Gregory,

OK, this helps, but..
I don't want to mix my Java sources with Hibernate definitions.
So I created another folder MyModule/hibernate.dir, marked it a source
folder. hibernate.cfg.xml can be placed in this folder (after adjusting
facet descriptor).
I created MyTables.hbm.xml in the same folder.
Again Idea complains that it can not resolve the file.
I moved MyTables.hbm.xml to src folder, and bingo: Idea can see it.

I suspect that Idea is looking for mapping resources in the hardcoded
'src' folder, instead of the path relative to hibernate.cfg.xml

Tom

Gregory Shrago (JetBrains) wrote:

Hello Tom,

The mapping file should be under some source root.

Regards,
Gregory Shrago

Tom wrote:

>> Hi,
>>
>> In 7M2 I created Hibernate facet associated with hibernate.cfg.xml
>> Something like this:
>> >> >> .... >> >> >> >> Idea can not resolve file MyTables.hbm.xml (it's displayed in red). >> Both files are in the same directory (project root). >> Did I miss some settings? >> In some other posting somebody said that mapping-resource is not fully >> supported yet. Will it be in the final version of Idea 7? >> >>]]> Tom

0

Tom,

I'm unable to reproduce the problem.
There is no errors in my setup that is similar to yours.
Please verify that that hibernate.cfg.xml contains valid references to
the mappings.

Regards,
Gregory Shrago

Tom wrote:

Gregory,

OK, this helps, but..
I don't want to mix my Java sources with Hibernate definitions.
So I created another folder MyModule/hibernate.dir, marked it a source
folder. hibernate.cfg.xml can be placed in this folder (after adjusting
facet descriptor).
I created MyTables.hbm.xml in the same folder.
Again Idea complains that it can not resolve the file.
I moved MyTables.hbm.xml to src folder, and bingo: Idea can see it.

I suspect that Idea is looking for mapping resources in the hardcoded
'src' folder, instead of the path relative to hibernate.cfg.xml

Tom

Gregory Shrago (JetBrains) wrote:

>> Hello Tom,
>>
>> The mapping file should be under some source root.
>>
>> Regards,
>> Gregory Shrago
>>
>> Tom wrote:
>>> Hi,
>>>
>>> In 7M2 I created Hibernate facet associated with hibernate.cfg.xml
>>> Something like this:
>>> >>> >>> .... >>> >>> >>> >>> Idea can not resolve file MyTables.hbm.xml (it's displayed in red). >>> Both files are in the same directory (project root). >>> Did I miss some settings? >>> In some other posting somebody said that mapping-resource is not fully >>> supported yet. Will it be in the final version of Idea 7? >>> >>>]]> Tom

0

Gregory,

You are right. I've tried to reproduce the problem by creating small
project, and I failed!

Anyway, thanks to you guys I discovered JPA. I'm now in the process of
moving my small Hibernate-only projects into standardized JPA interfaces
with Hibernate implementation.
If only Hibernate and JPA facets were new in 7M2 I would upgrade. I'm
sure there are many new features, which I didn't have time to discover.
Great work guys!

Tom

Gregory Shrago (JetBrains) wrote:

Tom,

I'm unable to reproduce the problem.
There is no errors in my setup that is similar to yours.
Please verify that that hibernate.cfg.xml contains valid references to
the mappings.

Regards,
Gregory Shrago

0

请先登录再写评论。