-
Notifications
You must be signed in to change notification settings - Fork 215
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
HBX-2864: Update Hibernate ORM Dependency to Version 7.0.0.Alpha3
Signed-off-by: Koen Aers <koen.aers@gmail.com>
- Loading branch information
Showing
23 changed files
with
118 additions
and
25 deletions.
There are no files selected for viewing
29 changes: 23 additions & 6 deletions
29
jbt/src/main/java/org/hibernate/tool/orm/jbt/internal/util/JpaMappingFileHelper.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,24 +1,41 @@ | ||
package org.hibernate.tool.orm.jbt.internal.util; | ||
|
||
import java.net.URL; | ||
import java.util.ArrayList; | ||
import java.util.Collection; | ||
import java.util.List; | ||
import java.util.Properties; | ||
|
||
import org.hibernate.jpa.boot.internal.ParsedPersistenceXmlDescriptor; | ||
import org.hibernate.jpa.boot.internal.PersistenceXmlParser; | ||
import org.hibernate.jpa.boot.spi.PersistenceUnitDescriptor; | ||
import org.hibernate.jpa.boot.spi.PersistenceXmlParser; | ||
|
||
public class JpaMappingFileHelper { | ||
|
||
public static List<String> findMappingFiles(String persistenceUnitName) { | ||
List<String> result = new ArrayList<String>(); | ||
List<ParsedPersistenceXmlDescriptor> persistenceUnits = | ||
PersistenceXmlParser.locatePersistenceUnits(new Properties()); | ||
for (ParsedPersistenceXmlDescriptor descriptor : persistenceUnits) { | ||
Collection<PersistenceUnitDescriptor> persistenceUnits = locatePersistenceUnits(); | ||
for (PersistenceUnitDescriptor descriptor : persistenceUnits) { | ||
if (descriptor.getName().equals(persistenceUnitName)) { | ||
result.addAll(descriptor.getMappingFileNames()); | ||
} | ||
} | ||
return result; | ||
} | ||
|
||
private static Collection<PersistenceUnitDescriptor> locatePersistenceUnits() { | ||
final Collection<PersistenceUnitDescriptor> units; | ||
try { | ||
var parser = PersistenceXmlParser.create(); | ||
final List<URL> xmlUrls = parser.getClassLoaderService().locateResources( "META-INF/persistence.xml" ); | ||
if ( xmlUrls.isEmpty() ) { | ||
units = List.of(); | ||
} | ||
else { | ||
units = parser.parse( xmlUrls ).values(); | ||
} | ||
} | ||
catch (Exception e) { | ||
throw new RuntimeException( "Unable to locate persistence units", e ); | ||
} | ||
return units; | ||
} | ||
} |
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
32 changes: 32 additions & 0 deletions
32
orm/src/main/java/org/hibernate/tool/internal/util/ValueUtil.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 |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package org.hibernate.tool.internal.util; | ||
|
||
import java.util.Collections; | ||
import java.util.Map; | ||
|
||
import org.hibernate.boot.spi.MetadataBuildingContext; | ||
import org.hibernate.mapping.BasicValue; | ||
import org.hibernate.mapping.SimpleValue; | ||
|
||
public class ValueUtil extends BasicValue { | ||
|
||
private static final long serialVersionUID = 1L; | ||
|
||
public ValueUtil(SimpleValue sv) { | ||
super(sv.getBuildingContext()); | ||
sv.getCustomIdGeneratorCreator(); | ||
} | ||
|
||
public ValueUtil(MetadataBuildingContext buildingContext) { | ||
super(buildingContext); | ||
} | ||
|
||
public Map<String, Object> getIdentifierGeneratorParameters() { | ||
getBuildingContext().getMetadataCollector().getIdentifierGenerator("foo"); | ||
return Collections.emptyMap(); | ||
} | ||
|
||
public String getIdentifierGeneratorStrategy() { | ||
return null; | ||
} | ||
|
||
} |
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
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
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
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
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
Oops, something went wrong.