-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
Showing
16 changed files
with
363 additions
and
214 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package hibernateLocal; | ||
|
||
import java.io.File; | ||
|
||
import org.hibernate.SessionFactory; | ||
import org.hibernate.cfg.Configuration; | ||
import org.onebusaway.gtfs.services.HibernateGtfsFactory; | ||
|
||
public class HibernateSession { | ||
private static final String KEY_CLASSPATH = "classpath:"; | ||
|
||
private static final String KEY_FILE = "file:"; | ||
|
||
|
||
protected String resource = null; | ||
|
||
public HibernateSession() { | ||
super(); | ||
this.resource = "file:src/hibernateLocal/hibernate-configuration.xml"; | ||
} | ||
|
||
public HibernateGtfsFactory createHibernateGtfsFactory() { | ||
|
||
Configuration config = new Configuration(); | ||
|
||
|
||
if (resource.startsWith(KEY_CLASSPATH)) { | ||
resource = resource.substring(KEY_CLASSPATH.length()); | ||
config = config.configure(resource); | ||
} else if (resource.startsWith(KEY_FILE)) { | ||
resource = resource.substring(KEY_FILE.length()); | ||
config = config.configure(new File(resource)); | ||
} else { | ||
config = config.configure(new File(resource)); | ||
} | ||
|
||
SessionFactory sessionFactory = config.buildSessionFactory(); | ||
return new HibernateGtfsFactory(sessionFactory); | ||
} | ||
|
||
} |
2 changes: 1 addition & 1 deletion
2
src/hibernate_handling/TestLoading.java → src/hibernateLocal/TestLoading.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package hibernate_handling; | ||
package hibernateLocal; | ||
|
||
|
||
import java.io.File; | ||
|
Oops, something went wrong.