Why is “hibernate.connection.autocommit = true” not recommended in Hibernate?

All database statements are executed within the context of a physical transaction, even when we don’t explicitly declare transaction boundaries (BEGIN/COMMIT/ROLLBACK). If you don’t declare the transaction boundaries, then each statement will have to be executed in a separate transaction. This may even lead to opening and closing one connection per statement. Declaring a service … Read more

Is 502 an appropriate status code for a database error?

No, I don’t think an HTTP 502 Bad Gateway error is appropriate when a database error occurs. HTTP errors say something about the HTTP protocol. This specific error indicates a server is trying to relay the HTTP request, but the upstream server did not respond correctly. Your web application communicating with a database server is … Read more

Map string column in Entity Framework to Enum

Probably a nicer version. OrderStateIdentifier field is used for both JSON serialization and database field, while OrderState is only used in the code for convenience. public string OrderStateIdentifier { get { return OrderState.ToString(); } set { OrderState = value.ToEnum<OrderState>(); } } [NotMapped] [JsonIgnore] public OrderState OrderState { get; set; } public static class EnumHelper { … Read more

postgres ‘psql’ command is not recognized in windows environment

Assuming you installed PostgreSQL on Windows with the PostgreSQL “One-click” installer packaged by EnterpriseDB, psql is not added to the PATH automatically. That’s partly because adding it to the path could otherwise cause confusion when people have multiple versions of PostgreSQL installed. You need to specify the full explicit path to psql, eg: “%PROGRAMFILES%\Postgresql\9.2\bin\psql.exe” or … Read more