PostgreSQL column type conversion from bigint to bigserial

As explained in the documentation, SERIAL is not a datatype, but a shortcut for a collection of other commands. So while you can’t change it simply by altering the type, you can achieve the same effect by running these other commands yourself: CREATE SEQUENCE temp_id_seq; ALTER TABLE temp ALTER COLUMN id SET NOT NULL; ALTER … Read more

Sharing a persistence unit across components in a .ear file

Here are the relevant sections of the JPA 2.0 specification: 8.2 Persistence Unit Packaging … A persistence unit is defined by a persistence.xml file. The jar file or directory whose META-INF directory contains the persistence.xml file is termed the root of the persistence unit. In Java EE environments, the root of a persistence unit must … Read more

What is the difference between business class and domain class? What is meant by persistent classes?

A domain class is a class from the Domain Model that Martin Fowler describes as follow in Patterns of Enterprise Application Architecture: An object model of the domain that incorporates both behavior and data. At its worst business logic can be very complex. Rules and logic describe many different cases and slants of behavior, and … Read more

How to properly pickle sklearn pipeline when using custom transformer

I found a pretty straightforward solution. Assuming you are using Jupyter notebooks for training: Create a .py file where the custom transformer is defined and import it to the Jupyter notebook. This is the file custom_transformer.py from sklearn.pipeline import TransformerMixin class FilterOutBigValuesTransformer(TransformerMixin): def __init__(self): pass def fit(self, X, y=None): self.biggest_value = X.c1.max() return self def … Read more

Yesod: Getting a database entity by ID from an Int

Even if the answer can already be found in the comments, I would like to give a complete example. Assuming we have a Person Model, the following function returns a record for the persion with the given ID (if it exists): import Database.Persist.Types (PersistValue(PersistInt64)) getByIntId :: Integral i => i -> Handler (Maybe Person) getByIntId … Read more

Difference between configuring data source in persistence.xml and in spring configuration files

It makes a huge difference if you’re in a JavaEE container. More than personal preference, you’re much better off if you follow the second approach with a few modifications. In the first case, you’re creating your own connection pool and do not profit from the existing connection pool in the container. Thus even if you … Read more

Is it possible to get gVim to remember window size?

Edit: Corrected my answer. The mentioned winsize sessionoption only refers to the vim internal window layout, not the external dimensions. If you use :mksession and load the session on vim startup with gvim -S Session.vim you can include the window position and size into the session by including winpos and resize in the sessionoptions, see … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)