1 Reply Latest reply on May 6, 2009 5:04 AM by Dave Ellery

    seam-gen enum types from postgres

    Dave Ellery Newbie

      ok so this is probably a pipe dream but,


      im using postgres 8.3 and seam 2.1.2.CR1


      I have created my DB schema with plenty of postgress TYPE's as enum's and I was wondering if there is a way to get seam-gen to automatically generate these enum's?


      or do i have to handle this manually?

        • 1. Re: seam-gen enum types from postgres
          Dave Ellery Newbie

          ok so I created enum's for all my postgres enums, but now when I do a select i get


          java.lang.ClassCastException: org.postgresql.util.PGobject cannot be cast to java.lang.String
               at org.hibernate.type.EnumType.nullSafeGet(EnumType.java:96)
               at org.hibernate.type.CustomType.nullSafeGet(CustomType.java:105)
               at org.hibernate.type.AbstractType.hydrate(AbstractType.java:81)
               at org.hibernate.persister.entity.AbstractEntityPersister.hydrate(AbstractEntityPersister.java:2096)
               at org.hibernate.loader.Loader.loadFromResultSet(Loader.java:1380)
               at org.hibernate.loader.Loader.instanceNotYetLoaded(Loader.java:1308)
               at org.hibernate.loader.Loader.getRow(Loader.java:1206)
               at org.hibernate.loader.Loader.getRowFromResultSet(Loader.java:580)
               at org.hibernate.loader.Loader.doQuery(Loader.java:701)
               at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:236)
               at org.hibernate.loader.Loader.doList(Loader.java:2220)
               at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2104)
               at org.hibernate.loader.Loader.list(Loader.java:2099)
               at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:378)
               at org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:338)
               at org.hibernate.engine.query.HQLQueryPlan.performList(HQLQueryPlan.java:172)
               at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1121)
               at org.hibernate.impl.QueryImpl.list(QueryImpl.java:79)
               at org.hibernate.console.HQLQueryPage.getList(HQLQueryPage.java:50)
               at org.hibernate.eclipse.console.views.QueryPageViewer$ContentProviderImpl.getElements(QueryPageViewer.java:117)
               at org.eclipse.jface.viewers.StructuredViewer.getRawChildren(StructuredViewer.java:937)
               at org.eclipse.jface.viewers.ColumnViewer.getRawChildren(ColumnViewer.java:703)
               at org.eclipse.jface.viewers.AbstractTableViewer.getRawChildren(AbstractTableViewer.java:1071)
               at org.eclipse.jface.viewers.StructuredViewer.getFilteredChildren(StructuredViewer.java:871)
               at org.eclipse.jface.viewers.StructuredViewer.getSortedChildren(StructuredViewer.java:994)
               at org.eclipse.jface.viewers.AbstractTableViewer.internalRefreshAll(AbstractTableViewer.java:685)
               at org.eclipse.jface.viewers.AbstractTableViewer.internalRefresh(AbstractTableViewer.java:633)
               at org.eclipse.jface.viewers.AbstractTableViewer.internalRefresh(AbstractTableViewer.java:620)
               at org.eclipse.jface.viewers.AbstractTableViewer$2.run(AbstractTableViewer.java:576)
               at org.eclipse.jface.viewers.StructuredViewer.preservingSelection(StructuredViewer.java:1365)
               at org.eclipse.jface.viewers.StructuredViewer.preservingSelection(StructuredViewer.java:1328)
               at org.eclipse.jface.viewers.AbstractTableViewer.inputChanged(AbstractTableViewer.java:574)
               at org.eclipse.jface.viewers.ContentViewer.setInput(ContentViewer.java:274)
               at org.eclipse.jface.viewers.StructuredViewer.setInput(StructuredViewer.java:1603)
               at org.hibernate.eclipse.console.views.QueryPageViewer.createTable(QueryPageViewer.java:221)
               at org.hibernate.eclipse.console.views.QueryPageViewer.createControl(QueryPageViewer.java:200)
               at org.hibernate.eclipse.console.views.QueryPageViewer.<init>(QueryPageViewer.java:157)
               at org.hibernate.eclipse.console.views.QueryPageTabView.rebuild(QueryPageTabView.java:114)
               at org.hibernate.eclipse.console.views.QueryPageTabView$1.contentsChanged(QueryPageTabView.java:78)
               at org.hibernate.eclipse.console.views.QueryPageTabView$1.intervalAdded(QueryPageTabView.java:88)
               at javax.swing.AbstractListModel.fireIntervalAdded(Unknown Source)
               at org.hibernate.console.QueryPageModel.add(QueryPageModel.java:67)
               at org.hibernate.console.KnownConfigurations$1.queryPageCreated(KnownConfigurations.java:89)
               at org.hibernate.console.ConsoleConfiguration.fireQueryPageCreated(ConsoleConfiguration.java:550)
               at org.hibernate.console.ConsoleConfiguration.access$5(ConsoleConfiguration.java:546)
               at org.hibernate.console.ConsoleConfiguration$4.execute(ConsoleConfiguration.java:522)
               at org.hibernate.console.execution.DefaultExecutionContext.execute(DefaultExecutionContext.java:64)
               at org.hibernate.console.ConsoleConfiguration.executeHQLQuery(ConsoleConfiguration.java:514)
               at org.hibernate.eclipse.hqleditor.HQLEditor.executeQuery(HQLEditor.java:416)
               at org.hibernate.eclipse.console.actions.ExecuteQueryAction.execute(ExecuteQueryAction.java:73)
               at org.hibernate.eclipse.console.actions.ExecuteQueryAction.run(ExecuteQueryAction.java:53)
               at org.eclipse.jface.action.Action.runWithEvent(Action.java:498)
               at org.hibernate.eclipse.console.actions.ExecuteQueryAction.runWithEvent(ExecuteQueryAction.java:57)
               at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection(ActionContributionItem.java:583)
               at org.eclipse.jface.action.ActionContributionItem.access$2(ActionContributionItem.java:500)
               at org.eclipse.jface.action.ActionContributionItem$6.handleEvent(ActionContributionItem.java:452)
               at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
               at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1003)
               at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3823)
               at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3422)
               at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2384)
               at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2348)
               at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2200)
               at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:495)
               at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:288)
               at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:490)
               at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
               at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:113)
               at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:193)
               at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
               at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
               at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:386)
               at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179)
               at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
               at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
               at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
               at java.lang.reflect.Method.invoke(Unknown Source)
               at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:549)
               at org.eclipse.equinox.launcher.Main.basicRun(Main.java:504)
               at org.eclipse.equinox.launcher.Main.run(Main.java:1236)




          which totally confuses me,


          game type annotations


               @Column(name = "game_type", nullable = false)
               @Enumerated(EnumType.ORDINAL)
               @NotNull
               public GameType getGameType() {
                    return this.gameType;
               }



          game type enum


          public enum GameType implements Serializable {
          
               //CREATE TYPE game_type AS ENUM('fps','strategy','racing');
               
               fps,
               strategy,
               racing;
               
          }



          I have also tried EnumType.STRING, but same result, am I totally missing something here?