[Hibernate-JIRA] Created: (HBX-1049) No class generated for tables with only PK columns
by Frank Langelage (JIRA)
No class generated for tables with only PK columns
---------------------------------------------------
Key: HBX-1049
URL: http://opensource.atlassian.com/projects/hibernate/browse/HBX-1049
Project: Hibernate Tools
Issue Type: Bug
Components: hbm2java
Affects Versions: 3.2.0.GA
Environment: MS SQL Server 2005 Express Edition, Sun JDK 1.5.0_15, Sun Solaris Sparc 10.
Hibernate Tools 3.2.0 GA.
Reporter: Frank Langelage
See http://forum.hibernate.org/viewtopic.php?p=2379128#2379128.
Inside my database the are some tables containing only PK fields, nothing else.
Both PK fields are also FK to different tables.
Example SQL:
CREATE TABLE [dbo].[BOMConfiguratorBOMTypes](
[bomcCode] [varchar](20) NOT NULL,
[bomtCode] [char](2) NOT NULL,
CONSTRAINT [PK_BOMConfiguratorBOMTypes_bomcCode_bomtCode] PRIMARY KEY CLUSTERED
(
[bomcCode] ASC,
[bomtCode] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
ALTER TABLE [dbo].[BOMConfiguratorBOMTypes] WITH CHECK ADD CONSTRAINT [FK_BOMConfiguratorBOMTypes_BOMConfigurators] FOREIGN KEY([bomcCode])
REFERENCES [dbo].[BOMConfigurators] ([bomcCode])
ON UPDATE CASCADE
GO
ALTER TABLE [dbo].[BOMConfiguratorBOMTypes] CHECK CONSTRAINT [FK_BOMConfiguratorBOMTypes_BOMConfigurators]
GO
ALTER TABLE [dbo].[BOMConfiguratorBOMTypes] WITH CHECK ADD CONSTRAINT [FK_BOMConfiguratorBOMTypes_BOMTypes] FOREIGN KEY([bomtCode])
REFERENCES [dbo].[BOMTypes] ([bomtCode])
ON UPDATE CASCADE
Hibernate Tools does not generate a class for it.
As soon as I add an additional column to such a table the class gets generated.
--
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
17 years, 9 months
[Hibernate-JIRA] Created: (HBX-1048) Table names which are already "camelcase" get false
by Frank Langelage (JIRA)
Table names which are already "camelcase" get false
---------------------------------------------------
Key: HBX-1048
URL: http://opensource.atlassian.com/projects/hibernate/browse/HBX-1048
Project: Hibernate Tools
Issue Type: Bug
Components: hbm2java
Affects Versions: 3.2.0.GA
Environment: MS SQL Server Express Edition, sun JDK 1.5.0_15 on Solaris Sparc 10
Reporter: Frank Langelage
See http://forum.hibernate.org/viewtopic.php?p=2379127#2379127.
This small diff fixes the problem for me.
If the tablename contains at least one upper case character and one lower case character the table name is taken as it is to use as the class name.
If only lower case or only upper case characters are found, the current algorithm is used (camlecase the table name).
jboss@sb2000:/home/jboss/Hibernate svn diff HibernateExt
Index: HibernateExt/tools/src/java/org/hibernate/cfg/reveng/DefaultReverseEngineeringStrategy.java
===================================================================
--- HibernateExt/tools/src/java/org/hibernate/cfg/reveng/DefaultReverseEngineeringStrategy.java (revision 14422)
+++ HibernateExt/tools/src/java/org/hibernate/cfg/reveng/DefaultReverseEngineeringStrategy.java (working copy)
@@ -128,7 +128,13 @@
public String tableToClassName(TableIdentifier tableIdentifier) {
String pkgName = settings.getDefaultPackageName();
- String className = toUpperCamelCase( tableIdentifier.getName() );
+ String tableName = tableIdentifier.getName();
+ String className;
+ if(tableName.matches(".*\\p{javaLowerCase}.*" ) && tableName.matches( ".*\\p{javaUpperCase}.*")) {
+ className = tableName;
+ } else {
+ className = toUpperCamelCase( tableName );
+ }
if(pkgName.length()>0) {
return StringHelper.qualify(pkgName, className);
--
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
17 years, 9 months