Question

This is my entity:

@Entity
@Table(name="log_shop")
public class LogShop {

    @Id
    @GeneratedValue
    private int id;

    private String platform;

    @Type(type="org.jadira.usertype.dateandtime.joda.PersistentDateTime")
    private DateTime logged;

    @ManyToOne
    private Player player;

    private String type;

    @Column(name="type_value")
    private String typeValue;

    @Column(name="shop_source")
    private String shopSource;

    @Column(name="buy_confirm")
    @Type(type="org.hibernate.type.NumericBooleanType")
    private boolean buyConfirm;

    @Column(name="buy_yes")
    @Type(type="org.hibernate.type.NumericBooleanType")
    private boolean buyYes;

    @Column(name="not_enough_coins")
    @Type(type="org.hibernate.type.NumericBooleanType")
    private boolean notEnoughCoins;

    @Column(name="not_enough_coins_yes")
    @Type(type="org.hibernate.type.NumericBooleanType")
    private boolean notEnoughCoinsYes;

    LogShop() {}

    public LogShop(String platform, DateTime logged, Player player, String type, String typeValue, String shopSource, boolean buyConfirm, boolean buyYes,
            boolean notEnoughCoins, boolean notEnoughCoinsYes) {
        this.platform = platform;
        this.logged = logged;
        this.player = player;
        this.type = type;
        this.typeValue = typeValue;
        this.shopSource = shopSource;
        this.buyConfirm = buyConfirm;
        this.buyYes = buyYes;
        this.notEnoughCoins = notEnoughCoins;
        this.notEnoughCoinsYes = notEnoughCoinsYes;
    }

}

At startup, Hibernate (with hbm2ddl validate) complains org.hibernate.HibernateException: Missing column: count in xxxxx.log_shop

But as you can see, there is no column named count referenced in the entity class. Why does Hibernate require it to be present in the database?

For full reference, here's the table:

CREATE TABLE `log_shop` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `platform` varchar(26) NOT NULL DEFAULT 'web',
  `logged` datetime NOT NULL,
  `player_id` int(11) NOT NULL,
  `type` varchar(26) NOT NULL,
  `type_value` varchar(26) NOT NULL,
  `shop_source` varchar(26) NOT NULL,
  `buy_confirm` int(1) NOT NULL,
  `buy_yes` int(1) NOT NULL,
  `not_enough_coins` int(1) NOT NULL,
  `not_enough_coins_yes` int(1) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
Was it helpful?

Solution

Well, that was stupid... Turns out I've accidentally applied @Table(name="log_shop") to another entity class as well, which does refer to a count column.

It would've been nice of Hibernate to mention which class and field this was about though.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top