[Hibernate-JIRA] Closed: (HHH-1428) PersistenceManager Pattern (request for comments)
by Steve Ebersole (JIRA)
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-1428?page=c... ]
Steve Ebersole closed HHH-1428.
-------------------------------
Closing stale resolved issues
> PersistenceManager Pattern (request for comments)
> -------------------------------------------------
>
> Key: HHH-1428
> URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-1428
> Project: Hibernate Core
> Issue Type: New Feature
> Environment: Thats the idea! Unknown db platform
> Reporter: Harold Eduardo Montoya
>
> Well, I am not sure if I am goint to tell you some stupid ideas. I apologize for that.
> Talking about Persistence we cannot limit ourselves to proper RDBMS's or other systems with proper JDBC drivers and proper structured query languages dialects. Hibernate is hot, but as a programmer i hav had to build a custom interface in order to hide Hibernate implementation because i wanted to use a unique PersistenceManager interface for persisting objects in any way. My first problem was when i wanted to persist dynabeans, but now there is some development activity in that sense. My main problem now was when i wanted to use the same PersistenceManager interface for a custom system with no JDBC drivers nor SQL dialect!
> I will try to explain a very simple scenario!
> /*
> * PersistenceManager Pattern
> */
> import org.persistence.PersistenceManagerFactory;
> import org.persistence.PersistenceManager;
> {
> PersistenceManagerFactory pmf = new PersistenceManagerFactory();
> /*
> * This step can be done through an xml config file parsed by digester
> * so we can also configurate the Persistence Manager in order to
> * set custom properties that does not belong to the PersistenceManager interface.
> */
> PersistenceManager pm = pmf.getPersistenceManager("org.persistence.HibernatePersistenceManager");
> /*
> * Some custom code that depends on the PersistenceManager implementation
> */
> pm.init();
> MyBean object = new MyBean();
> object.setName("pippo");
> object.setWhatever("whenever");
> pm.persist(object);
> }
> So, the init() and persist() implementation depends on your needs.
> JDBC? use current SessionFactory()
> EXOTIC SOCKET CONNECTION? implement your own exotic PersistenceManager
> EXOTIC TIBCO CONNECTION with XML messaging? implement your own ....
> and so on...
> Well, I hope you will at least read these comments and consider to write
> at least your opinion. I can accept an "it sucks..." as an opinion!
> thanks for your time!
> Cheers!
> Eduardo
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators....
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
15 years
[Hibernate-JIRA] Closed: (HHH-1124) Provide factory for IoC container configuration
by Steve Ebersole (JIRA)
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-1124?page=c... ]
Steve Ebersole closed HHH-1124.
-------------------------------
Closing stale resolved issues
> Provide factory for IoC container configuration
> -----------------------------------------------
>
> Key: HHH-1124
> URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-1124
> Project: Hibernate Core
> Issue Type: New Feature
> Components: core
> Reporter: Christian Bauer
> Assignee: Steve Ebersole
> Priority: Minor
>
> I remember an issue back in the H2 days about this, but couldn't find it again.
> We should provide an IoC configuration factory, out-of-the-box in Hibernate, very similar to what Seam has right now:
> public class HibernateFactory {
> private String cfgResourceName;
> private Properties cfgProperties;
> private Hashtable jndiProperties;
> private List<String> mappingClasses;
> private List<String> mappingFiles;
> private List<String> mappingJars;
> private List<String> mappingPackages;
> private List<String> mappingResources;
> public Object buildSessionFactory() throws Exception {
> AnnotationConfiguration acfg = new AnnotationConfiguration();
> // Programmatic configuration
> if (cfgProperties != null) {
> acfg.setProperties(cfgProperties);
> }
> // Prefix regular JNDI properties for Hibernate
> if (jndiProperties != null) {
> for (Iterator it = jndiProperties.entrySet().iterator(); it.hasNext();) {
> Map.Entry entry = (Map.Entry)it.next();
> acfg.setProperty(Environment.JNDI_PREFIX + "." + entry.getKey(),
> (String)entry.getValue() );
> }
> }
> // hibernate.cfg.xml configuration
> if (cfgProperties == null && cfgResourceName == null) {
> acfg.configure();
> } else if (cfgProperties == null && cfgResourceName != null) {
> acfg.configure(cfgResourceName);
> }
> // Mapping metadata
> if (mappingClasses != null)
> for(String className: mappingClasses)
> acfg.addAnnotatedClass(ReflectHelper.classForName(className));
> if (mappingFiles != null)
> for(String fileName: mappingFiles)
> acfg.addFile(fileName);
> if (mappingJars != null)
> for(String jarName: mappingJars)
> acfg.addJar( new File(jarName) );
> if (mappingPackages != null)
> for(String packageName: mappingPackages)
> acfg.addPackage(packageName);
> if (mappingResources != null)
> for(String resourceName: mappingResources)
> acfg.addResource(resourceName);
> return acfg.buildSessionFactory();
> }
> public String getCfgResourceName() {
> return cfgResourceName;
> }
> public void setCfgResourceName(String cfgFileName) {
> this.cfgResourceName = cfgFileName;
> }
> public Properties getCfgProperties() {
> return cfgProperties;
> }
> public void setCfgProperties(Properties cfgProperties) {
> this.cfgProperties = cfgProperties;
> }
> public List<String> getMappingClasses() {
> return mappingClasses;
> }
> public void setMappingClasses(List<String> mappingClasses) {
> this.mappingClasses = mappingClasses;
> }
> public List<String> getMappingFiles() {
> return mappingFiles;
> }
> public void setMappingFiles(List<String> mappingFiles) {
> this.mappingFiles = mappingFiles;
> }
> public List<String> getMappingJars() {
> return mappingJars;
> }
> public void setMappingJars(List<String> mappingJars) {
> this.mappingJars = mappingJars;
> }
> public List<String> getMappingPackages() {
> return mappingPackages;
> }
> public void setMappingPackages(List<String> mappingPackages) {
> this.mappingPackages = mappingPackages;
> }
> public List<String> getMappingResources() {
> return mappingResources;
> }
> public void setMappingResources(List<String> mappingResources) {
> this.mappingResources = mappingResources;
> }
> public Hashtable getJndiProperties() {
> return jndiProperties;
> }
> public void setJndiProperties(Hashtable jndiProperties) {
> this.jndiProperties = jndiProperties;
> }
> }
> (The reason for the separate jndiProperties is simple: We inject the same properties as for the JBoss Microcontainer, without the hibernate.* prefix.)
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators....
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
15 years
[Hibernate-JIRA] Closed: (HHH-1464) QueryException from Query.getReturnAliases when query uses "fetch"
by Steve Ebersole (JIRA)
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-1464?page=c... ]
Steve Ebersole closed HHH-1464.
-------------------------------
Closing stale resolved issues
> QueryException from Query.getReturnAliases when query uses "fetch"
> ------------------------------------------------------------------
>
> Key: HHH-1464
> URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-1464
> Project: Hibernate Core
> Issue Type: Bug
> Components: core
> Affects Versions: 3.1.2
> Environment: Hibernate 3.1.2
> OSX 10.3.9
> Java 1.4.2
> Reporter: Loren Rosen
> Assignee: Steve Ebersole
> Fix For: 3.2.0.alpha1, 3.1.3
>
> Attachments: Main.java
>
>
> Calling Query.getReturnAliases on a query containing a join fetch results in a QueryException. This also happens for Query.getReturnTypes.
> Here's the stack trace:
> [java] Exception in thread "main" org.hibernate.QueryException: fetch may not be used with scroll() or iterate() [from org.hibernate.auction.AuctionItem item left join fetch item.bids bid left join fetch bid.bidder order by item.ends desc]
> [java] at org.hibernate.hql.ast.tree.FromElement.setFetch(FromElement.java:391)
> [java] at org.hibernate.hql.ast.tree.FromElementFactory.createCollection(FromElementFactory.java:218)
> [java] at org.hibernate.hql.ast.tree.DotNode.dereferenceCollection(DotNode.java:262)
> [java] at org.hibernate.hql.ast.tree.DotNode.resolve(DotNode.java:200)
> [java] at org.hibernate.hql.ast.tree.FromReferenceNode.resolve(FromReferenceNode.java:94)
> [java] at org.hibernate.hql.ast.HqlSqlWalker.createFromJoinElement(HqlSqlWalker.java:313)
> [java] at org.hibernate.hql.antlr.HqlSqlBaseWalker.joinElement(HqlSqlBaseWalker.java:3268)
> [java] at org.hibernate.hql.antlr.HqlSqlBaseWalker.fromElement(HqlSqlBaseWalker.java:3060)
> [java] at org.hibernate.hql.antlr.HqlSqlBaseWalker.fromElementList(HqlSqlBaseWalker.java:2938)
> [java] at org.hibernate.hql.antlr.HqlSqlBaseWalker.fromClause(HqlSqlBaseWalker.java:688)
> [java] at org.hibernate.hql.antlr.HqlSqlBaseWalker.query(HqlSqlBaseWalker.java:544)
> [java] at org.hibernate.hql.antlr.HqlSqlBaseWalker.selectStatement(HqlSqlBaseWalker.java:281)
> [java] at org.hibernate.hql.antlr.HqlSqlBaseWalker.statement(HqlSqlBaseWalker.java:229)
> [java] at org.hibernate.hql.ast.QueryTranslatorImpl.analyze(QueryTranslatorImpl.java:218)
> [java] at org.hibernate.hql.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:158)
> [java] at org.hibernate.hql.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:109)
> [java] at org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:75)
> [java] at org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:54)
> [java] at org.hibernate.engine.query.QueryPlanCache.getHQLQueryPlan(QueryPlanCache.java:71)
> [java] at org.hibernate.impl.SessionFactoryImpl.getReturnAliases(SessionFactoryImpl.java:622)
> [java] at org.hibernate.impl.AbstractQueryImpl.getReturnAliases(AbstractQueryImpl.java:156)
> [java] at org.hibernate.auction.Main.viewAllAuctionsSlow(Main.java:52)
> [java] at org.hibernate.auction.Main.main(Main.java:158)
> I've attached an example; it's a slightly modified version of the Main class from the auction example in the hibernate distribution. There's
> nothing particularly special about it -- so far as I know any call to getReturnAliases with a query containing fetch results in the same
> exception.
> Note that a feature in the Hibernate Tools Eclipse plugin relies on getReturnAliases working consistently,
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators....
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
15 years
[Hibernate-JIRA] Closed: (HHH-1551) @Embedded should use the field name as a prefix for the fields of the embedded objects.
by Steve Ebersole (JIRA)
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-1551?page=c... ]
Steve Ebersole closed HHH-1551.
-------------------------------
Closing stale resolved issues
> @Embedded should use the field name as a prefix for the fields of the embedded objects.
> ---------------------------------------------------------------------------------------
>
> Key: HHH-1551
> URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-1551
> Project: Hibernate Core
> Issue Type: New Feature
> Components: core
> Affects Versions: 3.1.2
> Reporter: Michael Newcomb
> Original Estimate: 8h
> Remaining Estimate: 8h
>
> @Embeddable
> class Vector3f
> {
> double getX()
> double getY()
> double getZ()
> }
> @Entity
> class Foo
> {
> @Embedded
> Vector3f getVelocity();
> @Embedded
> Vector3f getOrientation();
> }
> I get some errors from Hibernate about multiple columns in the Foo table. The only way it works is if I add @AttributeOverrides and specify unique columns for each embedded object.
> @Entity
> class Foo
> {
> @Embedded
> @AttributeOverrides(
> {
> @AttributeOverride(name="x", column=@Column(name="velocity_x")),
> @AttributeOverride(name="x", column=@Column(name="velocity_y")),
> @AttributeOverride(name="x", column=@Column(name="velocity_z"))
> }
> Vector3f getVelocity();
> @Embedded
> @AttributeOverrides(
> {
> @AttributeOverride(name="x", column=@Column(name="orientation_x")),
> @AttributeOverride(name="x", column=@Column(name="orientation_y")),
> @AttributeOverride(name="x", column=@Column(name="orientation_z"))
> }
> Vector3f getOrientation();
> }
> This is, IMHO, incredibly stupid. We are embedding the structure of the embedded class... WTF good is the embedded class? What happens when I want to add a member? Or change the names?
> Now, in older JBoss versions, the CMP container added the field name of the embedded class as a prefix to the fields in the embedded class. Much like the above:
> velocity_x
> velocity_y
> velocity_z
> orientation_x
> orientation_y
> orientation_z
> Thanks,
> Michael
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators....
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
15 years
[Hibernate-JIRA] Closed: (HHH-918) impossible to move objects to another session
by Steve Ebersole (JIRA)
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-918?page=co... ]
Steve Ebersole closed HHH-918.
------------------------------
Closing stale resolved issues
> impossible to move objects to another session
> ----------------------------------------------
>
> Key: HHH-918
> URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-918
> Project: Hibernate Core
> Issue Type: Bug
> Components: core
> Environment: not relevant (but it was oracle on unix)
> Reporter: Peter Mutsaers
> Assignee: Gavin King
> Fix For: 3.1 rc 1
>
>
> 1. Object obj = s1.get(someclass, someid);
> 2. s1.clear(); // or s1.evict(obj);
> in another thread:
> 3. s2.lock(obj, LockMode,NONE);
> The s2.lock() results in:
> net.sf.hibernate.LazyInitializationException: Illegally attempted to associate a proxy with two open Sessions
> at net.sf.hibernate.proxy.LazyInitializer.setSession(LazyInitializer.java:152)
> at net.sf.hibernate.impl.SessionImpl.reassociateProxy(SessionImpl.java:1027)
> at net.sf.hibernate.impl.SessionImpl.unproxyAndReassociate(SessionImpl.java:1011)
> at net.sf.hibernate.impl.SessionImpl.lock(SessionImpl.java:1709)
> Looking in LazyInitializer.setSession() I see:
> if ( session!=null && session.isOpen() ) {
> //TODO: perhaps this should be some other RuntimeException...
> throw new LazyInitializationException("Illegally attempted to associate a proxy with two open Sessions");
> Indeed s1 is still open and the session field of the evicted object is not cleared, even when it is detached from s1. However the text of the exception is not quite accurate, since formally the object after s1.clear() is no longer associated with the first session. Hibernate falsely assumes here that as long as the session is open, the object is associated, as if no s1.evict() or s1.clear() had been taken place.
> According to the "Hibernate in action" book on page 116 section 4.1.1 an object is detached by session close/clear/evict, no difference is made between these. Now it seems that this is not fully the case.
> Should not the object(s) evicted/cleared from the session have their session field set to null? As it is, we can only move an object into another session if the first session has been fully closed.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators....
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
15 years