Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
HibernateMetadata.java
MetadataSources sources = new MetadataSources(...)
...
.addAnnotatedClasses( Item.class );
.buildMetadata();
MetadataSources sources = new MetadataSources(...)
...
.addAnnotatedClasses( Item.class );
.usingContext()
.setNamingStrategy( new MyNamingStrategy() )
.buildMetadata();
@gbadner

This comment has been minimized.

Copy link

@gbadner gbadner commented Apr 26, 2011

MetadataSources sources = new MetadataSources(...)
...
.addAnnotatedClasses( Item.class );
.usingContext()
.setNamingStrategy( new MyNamingStrategy() )
.buildMetadata();
.addResource( Item.hbm.xml )
.usingContext()
buildMetadata();

@gbadner

This comment has been minimized.

Copy link

@gbadner gbadner commented Apr 26, 2011

from steve's email:

MetadataSources sources = new MetadataSources(...);
sources.setNamingStrategy( strategy1 );
sources.addResource( "some/resource.xml" );
sources.setNamingStrategy( strategy2 );
sources.addResource( "some/resource2.xml" );

@sebersole

This comment has been minimized.

Copy link

@sebersole sebersole commented Apr 26, 2011

Gail, this last one was just an illustration. It is specifically something I do not want.

@sebersole

This comment has been minimized.

Copy link

@sebersole sebersole commented Apr 26, 2011

Btw, as I sent out the dev ml, John pointed out a typo in my original email that I think is causing some confusion...

buildMetadata() is meant to return Metadata, not MetadataSources:

Metadata metadata = new MetadataSources(...)
   ...
   .addAnnotatedClasses( Item.class )
   .buildMetadata();

Metadata metadata = new MetadataSources(...)
   ...
   .addAnnotatedClasses( Item.class )
   .usingContext()
     .setNamingStrategy( new MyNamingStrategy() )
     .buildMetadata();
@sebersole

This comment has been minimized.

Copy link

@sebersole sebersole commented Apr 26, 2011

hmm, apparently the markdown stuff does not work out very well...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment